ZQuest Classic Coverage Report


Directory: src/
File: src/zc/guys.cpp
Date: 2025-01-13 08:29:44
Exec Total Coverage
Lines: 9162 12152 75.4%
Functions: 357 415 86.0%
Branches: 7285 12881 56.6%

Line Branch Exec Source
1 #include <cstring>
2 #include <stdio.h>
3 #include "base/combo.h"
4 #include "base/general.h"
5 #include "base/zc_alleg.h"
6 #include "zc/guys.h"
7 #include "zc/replay.h"
8 #include "zc/zc_ffc.h"
9 #include "zc/zc_subscr.h"
10 #include "zc/zelda.h"
11 #include "base/zsys.h"
12 #include "base/msgstr.h"
13 #include "zc/maps.h"
14 #include "zc/hero.h"
15 #include "subscr.h"
16 #include "zc/ffscript.h"
17 #include "gamedata.h"
18 #include "defdata.h"
19 #include "zscriptversion.h"
20 #include "particles.h"
21 #include "base/zc_math.h"
22 #include "slopes.h"
23 #include "base/qrs.h"
24 #include "base/dmap.h"
25 #include "base/mapscr.h"
26 #include "base/misctypes.h"
27 #include "base/initdata.h"
28 #include "zc/combos.h"
29 extern particle_list particles;
30
31 extern ZModule zcm;
32 extern HeroClass Hero;
33 extern sprite_list guys, items, Ewpns, Lwpns, chainlinks, decorations;
34
35 int32_t repaircharge=0;
36 bool adjustmagic=false;
37 bool learnslash=false;
38 int32_t wallm_load_clk=0;
39 int32_t sle_x,sle_y,sle_cnt,sle_clk=0;
40 int32_t vhead=0;
41 int32_t guycarryingitem=0;
42
43 char *guy_string[eMAXGUYS];
44
45 void never_return(int32_t index);
46 void playLevelMusic();
47
48 // If an enemy is this far out of the playing field, just remove it.
49 #define OUTOFBOUNDS ((int32_t)y>((isSideViewGravity() && canfall(id))?192:352) || y<-176 || x<-256 || x > 512)
50 //#define NEWOUTOFBOUNDS ((int32_t)y>32767 || y<-32767 || x<-32767 || x > 32767)
51 #define IGNORE_SIDEVIEW_PLATFORMS (editorflags & ENEMY_FLAG14)
52 #define OFFGRID_ENEMY (editorflags & ENEMY_FLAG15)
53
54 1111861 void do_fix(zfix& coord, int32_t val, bool nearest_half = false)
55 {
56 1111861 int32_t c = coord.getInt();
57
2/2
✓ Branch 0 taken 267 times.
✓ Branch 1 taken 1111594 times.
1111861 if(nearest_half)
58 {
59
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1111594 times.
1111594 if (c < 0)
60 c -= val / 2;
61 1111594 else c += (val/2);
62 1111594 }
63 1111861 c -= c % val;
64 1111861 coord = c;
65 1111861 }
66
67 bool NEWOUTOFBOUNDS(zfix x, zfix y, zfix z)
68 {
69 return
70 (
71 (((int32_t)y) > FFCore.enemy_removal_point[spriteremovalY2])
72 || (((int32_t)y) < FFCore.enemy_removal_point[spriteremovalY1])
73 || (((int32_t)x) < FFCore.enemy_removal_point[spriteremovalX1])
74 || (((int32_t)x) > FFCore.enemy_removal_point[spriteremovalX2])
75 || (((int32_t)z) < FFCore.enemy_removal_point[spriteremovalZ1])
76 || (((int32_t)z) > FFCore.enemy_removal_point[spriteremovalZ2])
77 );
78 }
79
80 namespace
81 {
82 int32_t trapConstantHorizontalID;
83 int32_t trapConstantVerticalID;
84 int32_t trapLOSHorizontalID;
85 int32_t trapLOSVerticalID;
86 int32_t trapLOS4WayID;
87
88 int32_t cornerTrapID;
89 int32_t centerTrapID;
90
91 int32_t rockID;
92 int32_t zoraID;
93 int32_t statueID;
94 }
95
96 346 void identifyCFEnemies()
97 {
98 346 trapConstantHorizontalID=-1;
99 346 trapConstantVerticalID=-1;
100 346 trapLOSHorizontalID=-1;
101 346 trapLOSVerticalID=-1;
102 346 trapLOS4WayID=-1;
103 346 cornerTrapID=-1;
104 346 centerTrapID=-1;
105 346 rockID=-1;
106 346 zoraID=-1;
107 346 statueID=-1;
108
109
2/2
✓ Branch 0 taken 177152 times.
✓ Branch 1 taken 346 times.
177498 for(int32_t i=0; i<eMAXGUYS; i++)
110 {
111
3/4
✓ Branch 0 taken 341 times.
✓ Branch 1 taken 176811 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 341 times.
177152 if((guysbuf[i].flags&guy_trph) && trapLOSHorizontalID==-1)
112 341 trapLOSHorizontalID=i;
113
4/4
✓ Branch 0 taken 352 times.
✓ Branch 1 taken 176800 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 346 times.
177152 if((guysbuf[i].flags&guy_trpv) && trapLOSVerticalID==-1)
114 346 trapLOSVerticalID=i;
115
3/4
✓ Branch 0 taken 346 times.
✓ Branch 1 taken 176806 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 346 times.
177152 if((guysbuf[i].flags&guy_trp4) && trapLOS4WayID==-1)
116 346 trapLOS4WayID=i;
117
3/4
✓ Branch 0 taken 346 times.
✓ Branch 1 taken 176806 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 346 times.
177152 if((guysbuf[i].flags&guy_trplr) && trapConstantHorizontalID==-1)
118 346 trapConstantHorizontalID=i;
119
3/4
✓ Branch 0 taken 346 times.
✓ Branch 1 taken 176806 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 346 times.
177152 if((guysbuf[i].flags&guy_trpud) && trapConstantVerticalID==-1)
120 346 trapConstantVerticalID=i;
121
122
3/4
✓ Branch 0 taken 346 times.
✓ Branch 1 taken 176806 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 346 times.
177152 if((guysbuf[i].flags&guy_trap) && cornerTrapID==-1)
123 346 cornerTrapID=i;
124
3/4
✓ Branch 0 taken 346 times.
✓ Branch 1 taken 176806 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 346 times.
177152 if((guysbuf[i].flags&guy_trp2) && centerTrapID==-1)
125 346 centerTrapID=i;
126
127
3/4
✓ Branch 0 taken 346 times.
✓ Branch 1 taken 176806 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 346 times.
177152 if((guysbuf[i].flags&guy_rock) && rockID==-1)
128 346 rockID=i;
129
4/4
✓ Branch 0 taken 365 times.
✓ Branch 1 taken 176787 times.
✓ Branch 2 taken 21 times.
✓ Branch 3 taken 344 times.
177152 if((guysbuf[i].flags&guy_zora) && zoraID==-1)
130 344 zoraID=i;
131
132
4/4
✓ Branch 0 taken 406 times.
✓ Branch 1 taken 176746 times.
✓ Branch 2 taken 60 times.
✓ Branch 3 taken 346 times.
177152 if((guysbuf[i].flags & guy_fire) && statueID==-1)
133 346 statueID=i;
134 177152 }
135 346 }
136
137 32 int32_t random_layer_enemy()
138 {
139 32 int32_t cnt=count_layer_enemies();
140
141
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 if(cnt==0)
142 {
143 return eNONE;
144 }
145
146 32 int32_t ret=zc_oldrand()%cnt;
147 32 cnt=0;
148
149
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 for(int32_t i=0; i<6; ++i)
150 {
151
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(tmpscr->layermap[i]!=0)
152 {
153 32 mapscr *layerscreen=&TheMaps[(tmpscr->layermap[i]-1)*MAPSCRS]+tmpscr->layerscreen[i];
154
155
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 for(int32_t j=0; j<10; ++j)
156 {
157
2/4
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 140 times.
140 if(layerscreen->enemy[j]>0&&layerscreen->enemy[j]<MAXGUYS)
158 {
159
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 108 times.
140 if(cnt==ret)
160 {
161 32 return layerscreen->enemy[j];
162 }
163
164 108 ++cnt;
165 108 }
166 108 }
167 }
168 }
169
170 return eNONE;
171 32 }
172
173 49 int32_t count_layer_enemies()
174 {
175 49 int32_t cnt=0;
176
177
2/2
✓ Branch 0 taken 294 times.
✓ Branch 1 taken 49 times.
343 for(int32_t i=0; i<6; ++i)
178 {
179
2/2
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 79 times.
294 if(tmpscr->layermap[i]!=0)
180 {
181 79 mapscr *layerscreen=&TheMaps[(tmpscr->layermap[i]-1)*MAPSCRS]+tmpscr->layerscreen[i];
182
183
2/2
✓ Branch 0 taken 790 times.
✓ Branch 1 taken 79 times.
869 for(int32_t j=0; j<10; ++j)
184 {
185
2/2
✓ Branch 0 taken 370 times.
✓ Branch 1 taken 420 times.
790 if(layerscreen->enemy[j]!=0)
186 {
187 420 ++cnt;
188 420 }
189 790 }
190 79 }
191 294 }
192
193 49 return cnt;
194 }
195
196 211789 int32_t hero_on_wall()
197 {
198 211789 zfix lx = Hero.getX();
199 211789 zfix ly = Hero.getY();
200
201
202
203
4/4
✓ Branch 0 taken 189837 times.
✓ Branch 1 taken 21952 times.
✓ Branch 2 taken 8850 times.
✓ Branch 3 taken 180987 times.
211789 if(lx>=48 && lx<=192)
204 {
205
2/2
✓ Branch 0 taken 231 times.
✓ Branch 1 taken 180756 times.
180987 if(ly==32) return up+1;
206
207
2/2
✓ Branch 0 taken 283 times.
✓ Branch 1 taken 180473 times.
180756 if(ly==128) return down+1;
208 180473 }
209
210
4/4
✓ Branch 0 taken 194033 times.
✓ Branch 1 taken 17242 times.
✓ Branch 2 taken 21403 times.
✓ Branch 3 taken 172630 times.
211275 if(ly>=48 && ly<=112)
211 {
212
2/2
✓ Branch 0 taken 223 times.
✓ Branch 1 taken 172407 times.
172630 if(lx==32) return left+1;
213
214
2/2
✓ Branch 0 taken 172303 times.
✓ Branch 1 taken 104 times.
172407 if(lx==208) return right+1;
215 172303 }
216
217 210948 return 0;
218 211789 }
219
220 765531 bool tooclose(int32_t x,int32_t y,int32_t d)
221 {
222
2/2
✓ Branch 0 taken 567822 times.
✓ Branch 1 taken 197709 times.
765531 return (abs(int32_t(HeroX())-x)<d && abs(int32_t(HeroY())-y)<d);
223 }
224
225 3989892 bool enemy::overpit(enemy *e)
226 {
227 // This function (and shadow_overpit) has been broken since it was written, and only
228 // checked the same diagonal of the hitbox, over and over again. The bug is because both
229 // loops used the same variable name.
230 // Checking literally every pixel seems like overkill, so for now let's continue to
231 // do the single diagonal but just once. That's why the outer loop is commented out.
232
233 // for ( int32_t q = 0; q < hxsz; ++q )
234 {
235
2/2
✓ Branch 0 taken 36952798 times.
✓ Branch 1 taken 3970690 times.
40923488 for ( int32_t q = 0; q < hit_height; ++q )
236 {
237 //check every pixel of the hitbox
238
2/2
✓ Branch 0 taken 19202 times.
✓ Branch 1 taken 36933596 times.
36952798 if ( ispitfall(x+q+hxofs, y+q+hyofs) )
239 {
240 //if the hitbox is over a pit, we can't land
241 19202 return true;
242 }
243 36933596 }
244 }
245 3970690 return false;
246 3989892 }
247
248 12253321 bool enemy::shadow_overpit(enemy *e)
249 {
250 // for ( int32_t q = 0; q < hxsz; ++q )
251 {
252
2/2
✓ Branch 0 taken 176097480 times.
✓ Branch 1 taken 12226860 times.
188324340 for ( int32_t q = 0; q < hit_height; ++q )
253 {
254 //check every pixel of the hitbox
255
2/2
✓ Branch 0 taken 26461 times.
✓ Branch 1 taken 176071019 times.
176097480 if ( ispitfall(x+q+hxofs, y+q+hyofs+hit_height-2) )
256 {
257 //if the hitbox is over a pit, we can't land
258 26461 return true;
259 }
260 176071019 }
261 }
262 12226860 return false;
263 12253321 }
264
265 // Returns true iff a combo type or flag precludes enemy movement.
266 7430087 bool enemy::groundblocked(int32_t dx, int32_t dy, bool isKB)
267 {
268
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7430087 times.
7430087 if(moveflags & move_ignore_blockflags) return false;
269 7430087 int32_t c = COMBOTYPE(dx,dy);
270
4/4
✓ Branch 0 taken 4889799 times.
✓ Branch 1 taken 2540288 times.
✓ Branch 2 taken 1398275 times.
✓ Branch 3 taken 1142013 times.
9970375 bool pit_blocks = (!(moveflags & (move_can_pitwalk|move_only_pitwalk)) && (!(moveflags & move_can_pitfall) || !isKB));
271
3/6
✓ Branch 0 taken 2521964 times.
✓ Branch 1 taken 4908123 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2521964 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7430087 bool water_blocks = (!(moveflags & (move_can_waterwalk|move_only_waterwalk|move_only_shallow_waterwalk)) && (!(moveflags & move_can_waterdrown) || !isKB) && get_qr(qr_DROWN));
272
5/6
✓ Branch 0 taken 2581510 times.
✓ Branch 1 taken 4848577 times.
✓ Branch 2 taken 2579633 times.
✓ Branch 3 taken 1877 times.
✓ Branch 4 taken 2579633 times.
✗ Branch 5 not taken.
14860938 return c==cPIT || c==cPITB || c==cPITC ||
273
4/6
✓ Branch 0 taken 2579633 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2579633 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2430885 times.
✓ Branch 5 taken 148748 times.
2579633 c==cPITD || c==cPITR || (pit_blocks && ispitfall(dx,dy)) ||
274 // Block enemies type and block enemies flags
275
2/2
✓ Branch 0 taken 2574357 times.
✓ Branch 1 taken 2425609 times.
148748 combo_class_buf[c].block_enemies&1 ||
276
4/4
✓ Branch 0 taken 2571687 times.
✓ Branch 1 taken 2670 times.
✓ Branch 2 taken 2571440 times.
✓ Branch 3 taken 247 times.
2574357 MAPFLAG(dx,dy)==mfNOENEMY || MAPCOMBOFLAG(dx,dy)==mfNOENEMY ||
277
4/4
✓ Branch 0 taken 2570622 times.
✓ Branch 1 taken 818 times.
✓ Branch 2 taken 2570556 times.
✓ Branch 3 taken 66 times.
2571440 MAPFLAG(dx,dy)==mfNOGROUNDENEMY || MAPCOMBOFLAG(dx,dy)==mfNOGROUNDENEMY ||
278 // Check for ladder-only combos which aren't dried water
279
4/4
✓ Branch 0 taken 10626 times.
✓ Branch 1 taken 2559930 times.
✓ Branch 2 taken 10331 times.
✓ Branch 3 taken 295 times.
5140817 (combo_class_buf[c].ladder_pass&1 && !iswater_type(c)) ||
280 // Check for drownable water
281
4/4
✓ Branch 0 taken 571970 times.
✓ Branch 1 taken 1998291 times.
✓ Branch 2 taken 1900 times.
✓ Branch 3 taken 570070 times.
2570261 (water_blocks && !(isSideViewGravity()) && (iswaterex(MAPCOMBO(dx,dy), currmap, currscr, -1, dx, dy, false, false, true, false, false)));
282 2584151 }
283
284 // Returns true iff enemy is floating and blocked by a combo type or flag.
285 8647452 bool enemy::flyerblocked(int32_t dx, int32_t dy, int32_t special, bool isKB)
286 {
287
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8647452 times.
8647452 if(moveflags & move_ignore_blockflags) return false;
288
4/4
✓ Branch 0 taken 6549648 times.
✓ Branch 1 taken 2097804 times.
✓ Branch 2 taken 1749398 times.
✓ Branch 3 taken 348406 times.
10745256 bool pit_blocks = (!(moveflags & move_can_pitwalk) && (!(moveflags & move_can_pitfall) || !isKB));
289
3/4
✓ Branch 0 taken 6564155 times.
✓ Branch 1 taken 2083297 times.
✓ Branch 2 taken 2083297 times.
✗ Branch 3 not taken.
10730749 bool water_blocks = (!(moveflags & move_can_waterwalk) && (!(moveflags & move_can_waterdrown) || !isKB));
290
2/2
✓ Branch 0 taken 1200833 times.
✓ Branch 1 taken 7446619 times.
16094071 return ((special==spw_floater)&&
291
2/2
✓ Branch 0 taken 7436494 times.
✓ Branch 1 taken 10125 times.
7446619 ((COMBOTYPE(dx,dy)==cNOFLYZONE)||
292
2/2
✓ Branch 0 taken 7436375 times.
✓ Branch 1 taken 119 times.
7436494 (combo_class_buf[COMBOTYPE(dx,dy)].block_enemies&4)||
293
2/2
✓ Branch 0 taken 7436204 times.
✓ Branch 1 taken 171 times.
7436375 (MAPFLAG(dx,dy)==mfNOENEMY)||
294
2/2
✓ Branch 0 taken 7435949 times.
✓ Branch 1 taken 255 times.
7436204 (MAPCOMBOFLAG(dx,dy)==mfNOENEMY)||
295
4/4
✓ Branch 0 taken 1242529 times.
✓ Branch 1 taken 6193420 times.
✓ Branch 2 taken 4004 times.
✓ Branch 3 taken 1238525 times.
14867894 (water_blocks && iswaterex(MAPCOMBO(dx, dy), currmap, currscr, -1, dx,dy, false, false, true)) ||
296
2/2
✓ Branch 0 taken 6183831 times.
✓ Branch 1 taken 1248114 times.
7431945 (pit_blocks && ispitfall(dx,dy))));
297 8647452 }
298 // Returns true iff a combo type or flag precludes enemy movement.
299 268956 bool groundblocked(int32_t dx, int32_t dy, guydata const& gd)
300 {
301 268956 int32_t c = COMBOTYPE(dx,dy);
302 268956 bool pit_blocks = !(gd.moveflags & move_can_pitwalk);
303
2/2
✓ Branch 0 taken 33457 times.
✓ Branch 1 taken 235499 times.
268956 bool water_blocks = !(gd.moveflags & move_can_waterwalk) && get_qr(qr_DROWN);
304
5/6
✓ Branch 0 taken 268936 times.
✓ Branch 1 taken 20 times.
✓ Branch 2 taken 268819 times.
✓ Branch 3 taken 117 times.
✓ Branch 4 taken 268819 times.
✗ Branch 5 not taken.
1014715 return c==cPIT || c==cPITB || c==cPITC ||
305
4/6
✓ Branch 0 taken 268819 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 268819 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 239043 times.
✓ Branch 5 taken 29776 times.
268819 c==cPITD || c==cPITR || (pit_blocks && ispitfall(dx,dy)) ||
306 // Block enemies type and block enemies flags
307
2/2
✓ Branch 0 taken 268246 times.
✓ Branch 1 taken 238470 times.
29776 combo_class_buf[c].block_enemies&1 ||
308
4/4
✓ Branch 0 taken 267920 times.
✓ Branch 1 taken 326 times.
✓ Branch 2 taken 267889 times.
✓ Branch 3 taken 31 times.
268246 MAPFLAG(dx,dy)==mfNOENEMY || MAPCOMBOFLAG(dx,dy)==mfNOENEMY ||
309
4/4
✓ Branch 0 taken 264389 times.
✓ Branch 1 taken 3500 times.
✓ Branch 2 taken 264114 times.
✓ Branch 3 taken 275 times.
267889 MAPFLAG(dx,dy)==mfNOGROUNDENEMY || MAPCOMBOFLAG(dx,dy)==mfNOGROUNDENEMY ||
310 // Check for ladder-only combos which aren't dried water
311
4/4
✓ Branch 0 taken 1042 times.
✓ Branch 1 taken 263072 times.
✓ Branch 2 taken 1003 times.
✓ Branch 3 taken 39 times.
528189 (combo_class_buf[c].ladder_pass&1 && !iswater_type(c)) ||
312 // Check for drownable water
313
4/4
✓ Branch 0 taken 42397 times.
✓ Branch 1 taken 221678 times.
✓ Branch 2 taken 24004 times.
✓ Branch 3 taken 18393 times.
264075 (water_blocks && !(isSideViewGravity()) && (iswaterex(MAPCOMBO(dx,dy), currmap, currscr, -1, dx, dy, false, false, true)));
314 }
315
316 // Returns true iff enemy is floating and blocked by a combo type or flag.
317 122271 bool flyerblocked(int32_t dx, int32_t dy, int32_t special, guydata const& gd)
318 {
319
2/2
✓ Branch 0 taken 119948 times.
✓ Branch 1 taken 2323 times.
122271 bool pit_blocks = (!(gd.moveflags & move_can_pitwalk) && !(gd.moveflags & move_can_pitfall));
320 122271 bool water_blocks = !(gd.moveflags & move_can_waterwalk);
321
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 122271 times.
244542 return ((special==spw_floater)&&
322
2/2
✓ Branch 0 taken 122174 times.
✓ Branch 1 taken 97 times.
122271 ((COMBOTYPE(dx,dy)==cNOFLYZONE)||
323
2/2
✓ Branch 0 taken 122169 times.
✓ Branch 1 taken 5 times.
122174 (combo_class_buf[COMBOTYPE(dx,dy)].block_enemies&4)||
324
2/2
✓ Branch 0 taken 122160 times.
✓ Branch 1 taken 9 times.
122169 (MAPFLAG(dx,dy)==mfNOENEMY)||
325
2/2
✓ Branch 0 taken 122131 times.
✓ Branch 1 taken 29 times.
122160 (MAPCOMBOFLAG(dx,dy)==mfNOENEMY)||
326
4/4
✓ Branch 0 taken 2321 times.
✓ Branch 1 taken 119810 times.
✓ Branch 2 taken 250 times.
✓ Branch 3 taken 2071 times.
244012 (water_blocks && iswaterex(MAPCOMBO(dx,dy), currmap, currscr, -1, dx, dy, false, false, true)) ||
327
2/2
✓ Branch 0 taken 119810 times.
✓ Branch 1 taken 2071 times.
121881 (pit_blocks && ispitfall(dx,dy))));
328 }
329
330
5/10
✓ Branch 0 taken 114536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 114536 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 114536 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 114536 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 114536 times.
✗ Branch 9 not taken.
229072 enemy::enemy(zfix X,zfix Y,int32_t Id,int32_t Clk) : sprite()
331 114536 {
332
1/2
✓ Branch 0 taken 114536 times.
✗ Branch 1 not taken.
114536 x=X;
333
1/2
✓ Branch 0 taken 114536 times.
✗ Branch 1 not taken.
114536 y=Y;
334 114536 id=Id;
335 114536 clk=Clk;
336
1/2
✓ Branch 0 taken 114536 times.
✗ Branch 1 not taken.
114536 floor_y=y;
337 114536 ceiling=false;
338 114536 fading = misc = clk2 = clk3 = stunclk = hclk = sclk = superman = 0;
339 114536 grumble = movestatus = posframe = timer = ox = oy = 0;
340
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 114536 times.
✓ Branch 2 taken 114536 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 114536 times.
✗ Branch 5 not taken.
114536 yofs = (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) - ((isSideViewGravity()) ? 0 : 2);
341 114536 did_armos=true;
342 114536 script_spawned=false;
343
344 114536 d = guysbuf + (id & 0xFFF);
345 114536 hp = d->hp;
346 114536 starting_hp = hp;
347 // cs = d->cset;
348 //d variables
349
350 114536 flags=d->flags;
351 114536 flags=d->flags;
352 114536 s_tile=d->s_tile; //secondary (additional) tile(s)
353 114536 family=d->family;
354 114536 dcset=d->cset;
355 114536 cs=dcset;
356
2/2
✓ Branch 0 taken 88416 times.
✓ Branch 1 taken 26120 times.
114536 anim=get_qr(qr_NEWENEMYTILES)?d->e_anim:d->anim;
357 114536 dp=d->dp;
358 114536 wdp=d->wdp;
359 114536 wpn=d->weapon;
360 114536 wpnsprite = d-> wpnsprite; //2.6 -Z
361 114536 rate=d->rate;
362 114536 hrate=d->hrate;
363
1/2
✓ Branch 0 taken 114536 times.
✗ Branch 1 not taken.
114536 dstep=d->step;
364 114536 homing=d->homing;
365 114536 dmisc1=d->attributes[0];
366 114536 dmisc2=d->attributes[1];
367 114536 dmisc3=d->attributes[2];
368 114536 dmisc4=d->attributes[3];
369 114536 dmisc5=d->attributes[4];
370 114536 dmisc6=d->attributes[5];
371 114536 dmisc7=d->attributes[6];
372 114536 dmisc8=d->attributes[7];
373 114536 dmisc9=d->attributes[8];
374 114536 dmisc10=d->attributes[9];
375 114536 dmisc11=d->attributes[10];
376 114536 dmisc12=d->attributes[11];
377 114536 dmisc13=d->attributes[12];
378 114536 dmisc14=d->attributes[13];
379 114536 dmisc15=d->attributes[14];
380 114536 dmisc16=d->attributes[15];
381 114536 dmisc17=d->attributes[16];
382 114536 dmisc18=d->attributes[17];
383 114536 dmisc19=d->attributes[18];
384 114536 dmisc20=d->attributes[19];
385 114536 dmisc21=d->attributes[20];
386 114536 dmisc22=d->attributes[21];
387 114536 dmisc23=d->attributes[22];
388 114536 dmisc24=d->attributes[23];
389 114536 dmisc25=d->attributes[24];
390 114536 dmisc26=d->attributes[25];
391 114536 dmisc27=d->attributes[26];
392 114536 dmisc28=d->attributes[27];
393 114536 dmisc29=d->attributes[28];
394 114536 dmisc30=d->attributes[29];
395 114536 dmisc31=d->attributes[30];
396 114536 dmisc32=d->attributes[31];
397
2/2
✓ Branch 0 taken 4076 times.
✓ Branch 1 taken 110460 times.
114536 if (get_qr(qr_BROKEN_ATTRIBUTE_31_32))
398 {
399 110460 dmisc31 = dmisc32;
400 110460 dmisc32 = 0;
401 110460 }
402 114536 spr_shadow=d->spr_shadow;
403 114536 spr_death=d->spr_death;
404 114536 spr_spawn=d->spr_spawn;
405
406
2/2
✓ Branch 0 taken 4695976 times.
✓ Branch 1 taken 114536 times.
4810512 for(int32_t i=0; i<edefLAST255; i++)
407 4695976 defense[i]=d->defense[i];
408
409 114536 bgsfx=d->bgsfx;
410 114536 hitsfx=d->hitsfx;
411 114536 deadsfx=d->deadsfx;
412 114536 bosspal=d->bosspal;
413 114536 parent_script_UID = 0;
414
415 114536 frozentile = d->frozentile;
416
417 114536 frozencset = d->frozencset;
418 114536 frozenclock = 0;
419
2/2
✓ Branch 0 taken 1145360 times.
✓ Branch 1 taken 114536 times.
1259896 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = d->frozenmisc[q];
420
421
2/2
✓ Branch 0 taken 1947112 times.
✓ Branch 1 taken 114536 times.
2061648 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = 0;
422 //firesfx = 0; //t.b.a -Z
423 114536 isCore = true; //t.b.a
424 114536 parentCore = 0; //t.b.a
425
1/2
✓ Branch 0 taken 114536 times.
✗ Branch 1 not taken.
114536 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
426
427 114536 firesfx = d->firesfx;
428
2/2
✓ Branch 0 taken 3665152 times.
✓ Branch 1 taken 114536 times.
3779688 for ( int32_t q = 0; q < 32; q++ ) movement[q] = d->movement[q];
429
2/2
✓ Branch 0 taken 3665152 times.
✓ Branch 1 taken 114536 times.
3779688 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = d->new_weapon[q];
430
431 114536 script = d->script;
432 114536 weaponscript = d->weaponscript;
433
434
2/2
✓ Branch 0 taken 916288 times.
✓ Branch 1 taken 114536 times.
1030824 for ( int32_t q = 0; q < 8; q++ )
435 {
436 916288 initD[q] = d->initD[q];
437 //Z_scripterrlog("(enemy::enemy(zfix)): Loading weapon InitD[%d] to an enemy with a value of (%d)\n",q,d->weap_initiald[q]);
438 916288 weap_initiald[q] = d->weap_initiald[q];
439 916288 }
440
441 114536 stickclk = 0;
442 114536 submerged = false;
443 114536 didScriptThisFrame = false;
444 114536 ffcactivated = 0;
445 114536 hitdir = -1;
446 114536 dialogue_str = 0; //set by spawn flags.
447 114536 editorflags = d->editorflags; //set by Enemy Editor
448 //Set the drawing flag for this sprite.
449
1/2
✓ Branch 0 taken 114536 times.
✗ Branch 1 not taken.
114536 if ( (editorflags&ENEMY_FLAG12) ) { drawflags |= sprdrawflagALWAYSOLDDRAWS; }
450
451
452
2/2
✓ Branch 0 taken 8858 times.
✓ Branch 1 taken 105678 times.
114536 if(bosspal>-1)
453 {
454
1/2
✓ Branch 0 taken 8858 times.
✗ Branch 1 not taken.
8858 loadpalset(csBOSS,pSprite(bosspal));
455 8858 }
456
457
2/2
✓ Branch 0 taken 49827 times.
✓ Branch 1 taken 64709 times.
114536 if(bgsfx>-1)
458 {
459
1/2
✓ Branch 0 taken 49827 times.
✗ Branch 1 not taken.
49827 cont_sfx(bgsfx);
460 49827 }
461
462
2/2
✓ Branch 0 taken 88416 times.
✓ Branch 1 taken 26120 times.
114536 if(get_qr(qr_NEWENEMYTILES))
463 {
464 88416 o_tile=d->e_tile;
465 88416 frate = d->e_frate;
466 88416 }
467 else
468 {
469 26120 o_tile=d->tile;
470 26120 frate = d->frate;
471 }
472
473 114536 tile=0; //init to 0 here, but set it later.
474
475 114536 scripttile = -1;
476 114536 scriptflip = -1;
477 114536 do_animation = true;
478 114536 immortal = false;
479 114536 noSlide = false;
480 114536 deathexstate = -1;
481
482 114536 hashero=false;
483
484 // If they forgot the invisibility flag, here's another failsafe:
485
4/4
✓ Branch 0 taken 5791 times.
✓ Branch 1 taken 108745 times.
✓ Branch 2 taken 5697 times.
✓ Branch 3 taken 94 times.
114536 if(o_tile==0 && family!=eeSPINTILE)
486
1/2
✓ Branch 0 taken 5697 times.
✗ Branch 1 not taken.
5697 flags |= guy_invisible;
487
488 // step = d->step/100.0;
489 // To preserve the odd step values for Keese & Gleeok heads. -L
490
5/8
✓ Branch 0 taken 114536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 114536 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12145 times.
✓ Branch 5 taken 102391 times.
✓ Branch 6 taken 12145 times.
✗ Branch 7 not taken.
114536 if(dstep==62.0) dstep+=0.5;
491
5/8
✓ Branch 0 taken 102391 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 102391 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 699 times.
✓ Branch 5 taken 101692 times.
✓ Branch 6 taken 699 times.
✗ Branch 7 not taken.
102391 else if(dstep==89) dstep-=1/9;
492
493
5/10
✓ Branch 0 taken 114536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 114536 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 114536 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 114536 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 114536 times.
✗ Branch 9 not taken.
114536 step = zslongToFix(dstep*100);
494
495
496 114536 item_set = d->item_set;
497 114536 grumble = d->grumble;
498
499
2/2
✓ Branch 0 taken 89923 times.
✓ Branch 1 taken 24613 times.
114536 if(frate == 0)
500 24613 frate = 256;
501
502 114536 leader = itemguy = dying = scored = false;
503 114536 canfreeze = count_enemy = true;
504
1/2
✓ Branch 0 taken 114536 times.
✗ Branch 1 not taken.
114536 mainguy = !(flags & guy_doesnt_count);
505
1/2
✓ Branch 0 taken 114536 times.
✗ Branch 1 not taken.
114536 dir = zc_oldrand()&3;
506
507 //2.6 Enemy Editor Hit and TIle Sizes
508
4/6
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 114527 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 9 times.
114536 if ( ((d->SIZEflags&OVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
509 // al_trace("Enemy txsz:%i\n", txsz);
510
4/6
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 114527 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 9 times.
114536 if ( ((d->SIZEflags&OVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
511
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 114529 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
114536 if ( ((d->SIZEflags&OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0 ) hit_width = d->hxsz;
512
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 114529 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
114536 if ( ((d->SIZEflags&OVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0 ) hit_height = d->hysz;
513
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 114536 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
114536 if ( ((d->SIZEflags&OVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0 ) hzsz = d->hzsz;
514
1/2
✓ Branch 0 taken 114536 times.
✗ Branch 1 not taken.
114536 if ( (d->SIZEflags&OVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
515
1/2
✓ Branch 0 taken 114536 times.
✗ Branch 1 not taken.
114536 if ( (d->SIZEflags&OVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
516 // if ( (d->SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = d->hzofs;
517
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 114536 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
114536 if ( (d->SIZEflags&OVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
518
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114536 times.
114536 if ( (d->SIZEflags&OVERRIDE_DRAW_Y_OFFSET) != 0 )
519 {
520 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
521 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
522 }
523
524
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 114536 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
114536 if ( (d->SIZEflags&OVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
525
526 114536 SIZEflags = d->SIZEflags;
527
528
8/10
✓ Branch 0 taken 114287 times.
✓ Branch 1 taken 249 times.
✓ Branch 2 taken 366 times.
✓ Branch 3 taken 114170 times.
✓ Branch 4 taken 366 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 366 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✓ Branch 9 taken 365 times.
114536 if((wpn==ewBomb || wpn==ewSBomb) && family!=eeOTHER && family!=eeFIRE && (family!=eeWALK || dmisc2 != e2tBOMBCHU))
529 1 wpn = 0;
530
531 //tile should never be 0 after init --Z (failsafe)
532
4/6
✓ Branch 0 taken 114536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 114536 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 107957 times.
✓ Branch 5 taken 6579 times.
114536 if (tile <= 0 && FFCore.getQuestHeaderInfo(vZelda) >= 0x255) {tile = o_tile;}
533
534 //Moveflags; for gravity and pit interaction
535 114536 moveflags = d->moveflags;
536
3/4
✓ Branch 0 taken 114536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17662 times.
✓ Branch 3 taken 96874 times.
114536 if(!can_pitfall(false))
537 {
538 //Some enemies must not interact with pits. Force their flags, for sanity's sake.
539
2/4
✓ Branch 0 taken 17662 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17662 times.
✗ Branch 3 not taken.
17662 moveflags &= ~move_can_pitfall;
540
2/4
✓ Branch 0 taken 17662 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17662 times.
✗ Branch 3 not taken.
17662 moveflags &= ~move_can_waterdrown;
541 17662 }
542
543 114536 shieldCanBlock = get_qr(qr_GOHMA_UNDAMAGED_BUG)?true:false;
544
545
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 114536 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
114536 if (((d->weapoverrideFLAGS & OVERRIDE_TILE_WIDTH) != 0) && d->weap_tilew > 0) { weap_tilew = d->weap_tilew; if (weap_tilew > 1) extend = 3; }
546
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 114536 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
114536 if (((d->weapoverrideFLAGS & OVERRIDE_TILE_HEIGHT) != 0) && d->weap_tileh > 0) { weap_tileh = d->weap_tileh; if (weap_tileh > 1) extend = 3; }
547
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 114536 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
114536 if (((d->weapoverrideFLAGS & OVERRIDE_HIT_WIDTH) != 0) && d->weap_hxsz >= 0) weap_hxsz = d->weap_hxsz;
548
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 114536 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
114536 if (((d->weapoverrideFLAGS & OVERRIDE_HIT_HEIGHT) != 0) && d->weap_hysz >= 0) weap_hysz = d->weap_hysz;
549
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 114536 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
114536 if (((d->weapoverrideFLAGS & OVERRIDE_HIT_Z_HEIGHT) != 0) && d->weap_hzsz >= 0) weap_hzsz = d->weap_hzsz;
550
1/2
✓ Branch 0 taken 114536 times.
✗ Branch 1 not taken.
114536 if ((d->weapoverrideFLAGS & OVERRIDE_HIT_X_OFFSET) != 0) weap_hxofs = d->weap_hxofs;
551
1/2
✓ Branch 0 taken 114536 times.
✗ Branch 1 not taken.
114536 if ((d->weapoverrideFLAGS & OVERRIDE_HIT_Y_OFFSET) != 0) weap_hyofs = d->weap_hyofs;
552
1/2
✓ Branch 0 taken 114536 times.
✗ Branch 1 not taken.
114536 if ((d->weapoverrideFLAGS & OVERRIDE_DRAW_X_OFFSET) != 0) weap_xofs = (int32_t)d->weap_xofs;
553
1/2
✓ Branch 0 taken 114536 times.
✗ Branch 1 not taken.
114536 if ((d->weapoverrideFLAGS & OVERRIDE_DRAW_Y_OFFSET) != 0)
554 {
555 weap_yofs = (int32_t)d->weap_yofs; //This seems to be setting to +48 or something with any value set?! -Z
556 weap_yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
557 }
558 114536 weapoverrideFLAGS = d->weapoverrideFLAGS;
559 114536 wunblockable = d->wunblockable;
560 114536 wmoveflags = d->wmoveflags;
561
2/4
✓ Branch 0 taken 114536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 114536 times.
✗ Branch 3 not taken.
114536 wstep = zslongToFix(d->wstep*100);
562 114536 memcpy(burnsprs, d->burnsprs, sizeof(d->burnsprs));
563 114536 memcpy(light_rads, d->light_rads, sizeof(d->light_rads));
564 114536 specialsfx = d->specialsfx;
565 114536 }
566
567 598 int32_t enemy::getScriptUID() { return script_UID; }
568 void enemy::setScriptUID(int32_t new_id) { script_UID = new_id; }
569 114305 enemy::~enemy()
570 114305 {
571
2/4
✓ Branch 0 taken 114305 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 114305 times.
✗ Branch 3 not taken.
114305 FFCore.deallocateAllScriptOwned(ScriptType::NPC, getUID());
572
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 114292 times.
114305 if(hashero)
573 {
574
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 Hero.setEaten(0);
575 13 hashero=false;
576 13 }
577 114305 }
578
579 bool enemy::is_move_paused()
580 {
581 return (clk<0 || dying || stunclk || watch || ceiling || frozenclock || fallclk || drownclk);
582 }
583
584 7024 bool enemy::scr_walkflag(int32_t dx,int32_t dy,int32_t special, int32_t dir, int32_t input_x, int32_t input_y, bool kb)
585 {
586 7024 int32_t yg = (special==spw_floater)?8:0;
587 7024 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
588 //Z_eventlog("Checking x,y %d,%d\n",dx,dy);
589
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 if(input_x == -1000)
590 input_x = dx;
591
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 if(input_y == -1000)
592 input_y = dy;
593
594
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7024 times.
14048 if(!(moveflags & move_ignore_screenedge)
595
4/6
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7024 times.
✓ Branch 4 taken 6707 times.
✓ Branch 5 taken 317 times.
7024 && ((input_x<(16-nb)) || (input_y<zc_max(16-yg-nb,0))
596
2/4
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7024 times.
✗ Branch 3 not taken.
7024 || ((input_x+hit_width-1) >= (240+nb)) || ((input_y+hit_height-1) >= (160+nb))))
597 return true;
598
599
4/6
✓ Branch 0 taken 90 times.
✓ Branch 1 taken 6934 times.
✓ Branch 2 taken 90 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 90 times.
✗ Branch 5 not taken.
7024 if(!(moveflags & move_can_pitwalk) && (!(moveflags & move_can_pitfall) || !kb)) //Don't walk into pits, unless being knocked back
600 {
601 if(ispitfall(dx,dy))
602 return true;
603 }
604
605 7024 bool flying = false;
606 7024 bool cansolid = false;
607
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 if(moveflags & move_ignore_solidity)
608 cansolid = true;
609
2/4
✓ Branch 0 taken 317 times.
✓ Branch 1 taken 6707 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7024 switch(special)
610 {
611 case spw_clipbottomright:
612 if(dy>=128 || dx>=208) return true;
613 break;
614 case spw_clipright:
615 break; //if(input_x>=208) return true; break;
616
617 case spw_wizzrobe: // fall through
618 case spw_floater: // Special case for fliers and wizzrobes - hack!
619 {
620
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 317 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
317 if(isdungeon() && !(moveflags & move_ignore_screenedge))
621 {
622 if(dy < 32-yg || dy >= 144) return true;
623 if(dx < 32 || dx >= 224) return true;
624 }
625
2/4
✓ Branch 0 taken 317 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 317 times.
✗ Branch 3 not taken.
317 if(!(moveflags & move_ignore_blockflags) && flyerblocked(dx, dy, special, kb))
626 return true;
627 317 cansolid = true;
628 317 flying = true;
629 }
630 317 }
631
632 7024 dx &= ~7;
633 7024 dy &= ~7;
634
635
4/6
✓ Branch 0 taken 6707 times.
✓ Branch 1 taken 317 times.
✓ Branch 2 taken 6707 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6707 times.
✗ Branch 5 not taken.
7024 if(!flying && !(moveflags & move_ignore_blockflags) && groundblocked(dx,dy,kb)) return true;
636
637
4/8
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7024 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7024 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 7024 times.
7024 if (dx < 0 || dx > 255 || dy < 0 || dy > 175)
638 return !(moveflags & move_ignore_screenedge);
639 //_walkflag code
640 mapscr *s1, *s2;
641 7024 s1=(((*tmpscr).layermap[0]-1)>=0)?tmpscr2:NULL;
642 7024 s2=(((*tmpscr).layermap[1]-1)>=0)?tmpscr2+1:NULL;
643
644 7024 int32_t cpos=(dx>>4)+(dy&0xF0);
645
3/4
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1038 times.
✓ Branch 3 taken 5986 times.
7024 int32_t ci = tmpscr->data[cpos], ci1 = (s1?s1:tmpscr)->data[cpos], ci2 = (s2?s2:tmpscr)->data[cpos];
646 7024 newcombo const& c = combobuf[ci];
647 7024 newcombo const& c1 = combobuf[ci1];
648 7024 newcombo const& c2 = combobuf[ci2];
649
650 7024 int32_t b=1;
651
2/2
✓ Branch 0 taken 3446 times.
✓ Branch 1 taken 3578 times.
7024 if(dx&8) b<<=2;
652
2/2
✓ Branch 0 taken 3374 times.
✓ Branch 1 taken 3650 times.
7024 if(dy&8) b<<=1;
653
654 #define iwtr(cmb, x, y, shallow) \
655 (shallow \
656 ? iswaterex(cmb, currmap, currscr, -1, dx, dy, false, false, false, true, false) \
657 && !iswaterex(cmb, currmap, currscr, -1, dx, dy, false, false, false, false, false) \
658 : iswaterex(cmb, currmap, currscr, -1, dx, dy, false, false, false, false, false))
659 7024 bool wtr = iwtr(ci, dx, dy, false);
660
2/2
✓ Branch 0 taken 3551 times.
✓ Branch 1 taken 3473 times.
7024 bool shwtr = iwtr(ci, dx, dy, true);
661 7024 bool pit = ispitfall(dx,dy);
662
663
3/4
✓ Branch 0 taken 6934 times.
✓ Branch 1 taken 90 times.
✓ Branch 2 taken 90 times.
✗ Branch 3 not taken.
7024 bool canwtr = (moveflags & move_can_waterwalk) || ((moveflags & move_can_waterdrown) && kb);
664
3/4
✓ Branch 0 taken 6934 times.
✓ Branch 1 taken 90 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 90 times.
7024 bool canpit = (moveflags & move_can_pitwalk) || ((moveflags & move_can_pitfall) && kb);
665 7024 bool needwtr = (moveflags & move_only_waterwalk);
666 7024 bool needshwtr = (moveflags & move_only_shallow_waterwalk);
667 7024 bool needpit = (moveflags & move_only_pitwalk);
668
669
2/2
✓ Branch 0 taken 317 times.
✓ Branch 1 taken 6707 times.
7024 if(!cansolid)
670 {
671 6707 int32_t cwalkflag = c.walk & 0xF;
672
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6707 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6707 if (c.type == cBRIDGE && get_qr(qr_OLD_BRIDGE_COMBOS)) cwalkflag = 0;
673
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6707 times.
6707 if (s1)
674 {
675
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6707 times.
6707 if (c1.type == cBRIDGE)
676 {
677 if (!get_qr(qr_OLD_BRIDGE_COMBOS))
678 {
679 int efflag = (c1.walk & 0xF0)>>4;
680 int newsolid = (c1.walk & 0xF);
681 cwalkflag = ((newsolid | cwalkflag) & (~efflag)) | (newsolid & efflag);
682 }
683 else cwalkflag &= c1.walk;
684 }
685 6707 else cwalkflag |= c1.walk & 0xF;
686 6707 }
687
2/2
✓ Branch 0 taken 5986 times.
✓ Branch 1 taken 721 times.
6707 if (s2)
688 {
689
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 721 times.
721 if (c2.type == cBRIDGE)
690 {
691 if (!get_qr(qr_OLD_BRIDGE_COMBOS))
692 {
693 int efflag = (c2.walk & 0xF0)>>4;
694 int newsolid = (c2.walk & 0xF);
695 cwalkflag = ((newsolid | cwalkflag) & (~efflag)) | (newsolid & efflag);
696 }
697 else cwalkflag &= c2.walk;
698 }
699 721 else cwalkflag |= c2.walk & 0xF;
700 721 }
701
2/2
✓ Branch 0 taken 239 times.
✓ Branch 1 taken 6468 times.
6707 if(cwalkflag & b)
702 239 return true;
703 6468 }
704
3/6
✓ Branch 0 taken 6785 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6785 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6785 times.
6785 if(needwtr || needshwtr || needpit)
705 {
706 bool ret = true;
707 if (needwtr && wtr) ret = false;
708 else if (needshwtr && shwtr) ret = false;
709 else if (needpit && pit) ret = false;
710 return ret;
711 }
712
3/4
✓ Branch 0 taken 3473 times.
✓ Branch 1 taken 3312 times.
✓ Branch 2 taken 3473 times.
✗ Branch 3 not taken.
6785 else if(wtr && !canwtr)
713 return true;
714
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6785 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6785 else if(pit && !canpit)
715 return true;
716
717 6785 return false;
718 7024 }
719
720 1535 bool enemy::scr_canmove(zfix dx, zfix dy, int32_t special, bool kb, bool ign_sv)
721 {
722
3/4
✓ Branch 0 taken 424 times.
✓ Branch 1 taken 1111 times.
✓ Branch 2 taken 424 times.
✗ Branch 3 not taken.
1535 if(!(dx || dy)) return true;
723 1535 zfix bx = x+hxofs, by = y+hyofs; //left/top
724 1535 zfix rx = bx+hit_width-1, ry = by+hit_height-1; //right/bottom
725
3/4
✓ Branch 0 taken 1019 times.
✓ Branch 1 taken 516 times.
✓ Branch 2 taken 1019 times.
✗ Branch 3 not taken.
1535 if(!ign_sv && dy < 0) //check gravity
726 {
727 if((moveflags & move_obeys_grav) && isSideViewGravity())
728 return false;
729 }
730
731
2/4
✓ Branch 0 taken 1535 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1535 times.
1535 bool nosolid = !((moveflags & move_ignore_solidity) || (special==spw_wizzrobe) || (special==spw_floater));
732
733
3/4
✓ Branch 0 taken 1111 times.
✓ Branch 1 taken 424 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1111 times.
1535 if(dx && !dy)
734 {
735
2/2
✓ Branch 0 taken 770 times.
✓ Branch 1 taken 341 times.
1111 if(dx < 0)
736 {
737
2/4
✓ Branch 0 taken 770 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 770 times.
770 special = (special==spw_clipbottomright||special==spw_clipright)?spw_none:special;
738 770 int mx = (bx+dx).getFloor();
739
2/2
✓ Branch 0 taken 2976 times.
✓ Branch 1 taken 770 times.
3746 for(zfix ty = 0; by+ty < ry; ty += 8)
740 {
741
1/2
✓ Branch 0 taken 2976 times.
✗ Branch 1 not taken.
2976 if(scr_walkflag(mx, by+ty, special, left, mx, by, kb))
742 return false;
743 2976 }
744
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 770 times.
770 if(scr_walkflag(mx, ry, special, left, mx, by, kb))
745 return false;
746
3/4
✓ Branch 0 taken 736 times.
✓ Branch 1 taken 34 times.
✓ Branch 2 taken 736 times.
✗ Branch 3 not taken.
770 if(nosolid && collide_object(bx+dx,by,-dx,hit_height,this))
747 return false;
748 770 }
749 else
750 {
751 341 int mx = (rx+dx).getCeil();
752 341 int lx = mx-hit_width+1;
753
2/2
✓ Branch 0 taken 2142 times.
✓ Branch 1 taken 340 times.
2482 for(zfix ty = 0; by+ty < ry; ty += 8)
754 {
755
2/2
✓ Branch 0 taken 2141 times.
✓ Branch 1 taken 1 times.
2142 if(scr_walkflag(mx, by+ty, special, right, lx, by, kb))
756 1 return false;
757 2141 }
758
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 340 times.
340 if(scr_walkflag(mx, ry, special, right, lx, by, kb))
759 return false;
760
2/4
✓ Branch 0 taken 340 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 340 times.
✗ Branch 3 not taken.
340 if(nosolid && collide_object(bx+hit_width,by,dx,hit_height,this))
761 return false;
762 }
763 1110 }
764
2/4
✓ Branch 0 taken 424 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 424 times.
424 else if(dy && !dx)
765 {
766
2/2
✓ Branch 0 taken 315 times.
✓ Branch 1 taken 109 times.
424 if(dy < 0)
767 {
768
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 315 times.
315 special = (special==spw_clipbottomright)?spw_none:special;
769 315 int my = (by+dy).getFloor();
770
2/2
✓ Branch 0 taken 392 times.
✓ Branch 1 taken 77 times.
469 for(zfix tx = 0; bx+tx < rx; tx += 8)
771 {
772
2/2
✓ Branch 0 taken 154 times.
✓ Branch 1 taken 238 times.
392 if(scr_walkflag(bx+tx, my, special, up, bx, my, kb))
773 238 return false;
774 154 }
775
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(scr_walkflag(rx, my, special, up, bx, my, kb))
776 return false;
777
3/4
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
77 if(nosolid && collide_object(bx,by+dy,hit_width,-dy,this))
778 return false;
779 77 }
780 else
781 {
782 109 int my = (ry+dy).getCeil();
783 109 int ly = my-hit_height+1;
784
2/2
✓ Branch 0 taken 218 times.
✓ Branch 1 taken 109 times.
327 for(zfix tx = 0; bx+tx < rx; tx += 8)
785 {
786
1/2
✓ Branch 0 taken 218 times.
✗ Branch 1 not taken.
218 if(scr_walkflag(bx+tx, my, special, down, bx, ly, kb))
787 return false;
788 218 }
789
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109 times.
109 if(scr_walkflag(rx, my, special, down, bx, ly, kb))
790 return false;
791
3/4
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 89 times.
109 if(nosolid && collide_object(bx,by+hit_height,hit_width,dy,this))
792 return false;
793 }
794 186 }
795 else //! Untested, and currently unused.
796 {
797 return scr_canmove(dx, 0, special, kb, ign_sv) && scr_canmove(dy, 0, special, kb, ign_sv);
798 }
799 1296 return true;
800 1535 }
801
802 bool enemy::scr_canplace(zfix dx, zfix dy, int32_t special, bool kb)
803 {
804 zfix bx = dx+hxofs, by = dy+hyofs; //left/top
805 zfix rx = bx+hit_width-1, ry = by+hit_height-1; //right/bottom
806
807 bool nosolid = !((moveflags & move_ignore_solidity) || (special==spw_wizzrobe) || (special==spw_floater));
808
809 if(nosolid && collide_object(bx,by,hit_width,hit_height,this))
810 return false;
811 for(zfix ty = 0; by+ty < ry; ty += 8)
812 {
813 for(zfix tx = 0; bx+tx < rx; tx += 8)
814 {
815 if(scr_walkflag(bx+tx, by+ty, special, -1, -1000, -1000, kb))
816 return false;
817 }
818 if(scr_walkflag(rx, by+ty, special, -1, -1000, -1000, kb))
819 return false;
820 }
821 for(zfix tx = 0; bx+tx < rx; tx += 8)
822 {
823 if(scr_walkflag(bx+tx, ry, special, -1, -1000, -1000, kb))
824 return false;
825 }
826 if(scr_walkflag(rx, ry, special, -1, -1000, -1000, kb))
827 return false;
828 return true;
829 }
830
831 bool enemy::scr_canplace(zfix dx, zfix dy, int32_t special, bool kb, int32_t nwid, int32_t nhei)
832 {
833 auto oxsz = hit_width, oysz = hit_height;
834 if(nwid > -1) hit_width = nwid;
835 if(nhei > -1) hit_height = nhei;
836 bool ret = scr_canplace(dx,dy,special,kb);
837 hit_width = oxsz; hit_height = oysz;
838 return ret;
839 }
840
841 1311 bool enemy::movexy(zfix dx, zfix dy, int32_t special, bool kb, bool ign_sv, bool earlyret)
842 {
843 1311 bool ret = true;
844
3/8
✓ Branch 0 taken 1019 times.
✓ Branch 1 taken 292 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1019 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1311 if(!ign_sv && dy < 0 && (moveflags & move_obeys_grav) && isSideViewGravity())
845 dy = 0;
846 1311 const int scl = 2;
847
4/4
✓ Branch 0 taken 260 times.
✓ Branch 1 taken 1345 times.
✓ Branch 2 taken 294 times.
✓ Branch 3 taken 1311 times.
1605 while(abs(dx) > scl || abs(dy) > scl)
848 {
849
2/2
✓ Branch 0 taken 260 times.
✓ Branch 1 taken 34 times.
294 if(abs(dx) > abs(dy))
850 {
851 260 int32_t tdx = dx.sign() * scl;
852
1/2
✓ Branch 0 taken 260 times.
✗ Branch 1 not taken.
260 if(movexy(tdx, 0, special, kb, ign_sv, earlyret))
853 260 dx -= tdx;
854 else
855 {
856 if(earlyret) return false;
857 dx = tdx;
858 ret = false;
859 }
860 260 }
861 else
862 {
863 34 int32_t tdy = dy.sign() * scl;
864
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 7 times.
34 if(movexy(0, tdy, special, kb, ign_sv, earlyret))
865 27 dy -= tdy;
866 else
867 {
868
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(earlyret) return false;
869 7 dy = tdy;
870 7 ret = false;
871 }
872 }
873 }
874
875
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 1111 times.
1311 if(dx)
876 {
877
2/2
✓ Branch 0 taken 1110 times.
✓ Branch 1 taken 1 times.
1111 if(scr_canmove(dx, 0, special, kb, ign_sv))
878 1110 x += dx;
879 else
880 {
881
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(earlyret) return false;
882 ret = false;
883 int xsign = dx.sign();
884 while(scr_canmove(xsign, 0, special, kb, ign_sv))
885 {
886 x += xsign;
887 dx -= xsign;
888 }
889 if(dx)
890 {
891 dx.doDecBound(0,-9999, 0,9999);
892 dx = binary_search_zfix(dx.decsign(), dx, [&](zfix val, zfix& retval){
893 if(scr_canmove(val, 0, special, kb, ign_sv))
894 {
895 retval = val;
896 return BSEARCH_CONTINUE_AWAY0;
897 }
898 else return BSEARCH_CONTINUE_TOWARD0;
899 });
900 x += dx;
901 }
902 }
903 1110 }
904
2/2
✓ Branch 0 taken 1110 times.
✓ Branch 1 taken 200 times.
1310 if(dy)
905 {
906
2/2
✓ Branch 0 taken 186 times.
✓ Branch 1 taken 14 times.
200 if(scr_canmove(0, dy, special, kb, ign_sv))
907 186 y += dy;
908 else
909 {
910
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(earlyret) return false;
911 14 ret = false;
912 14 int ysign = dy.sign();
913
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 while(scr_canmove(0, ysign, special, kb, ign_sv))
914 {
915 y += ysign;
916 dy -= ysign;
917 }
918
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(dy)
919 {
920 14 dy.doDecBound(0,-9999, 0,9999);
921
3/6
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
224 dy = binary_search_zfix(dy.decsign(), dy, [&](zfix val, zfix& retval){
922
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 210 times.
210 if(scr_canmove(0, val, special, kb, ign_sv))
923 {
924 retval = val;
925 return BSEARCH_CONTINUE_AWAY0;
926 }
927 210 else return BSEARCH_CONTINUE_TOWARD0;
928 210 });
929 14 y += dy;
930 14 }
931 }
932 200 }
933 1310 return ret;
934 1311 }
935
936 754 bool enemy::moveDir(int32_t dir, zfix px, int32_t special, bool kb, bool earlyret)
937 {
938
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 752 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
754 static const zfix diagrate = zslongToFix(7071);
939
5/13
✓ Branch 0 taken 754 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 754 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 16 times.
✓ Branch 6 taken 479 times.
✓ Branch 7 taken 259 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
754 switch(NORMAL_DIR(dir))
940 {
941 case up:
942 return movexy(0, -px, special, kb, false, earlyret);
943 case down:
944 16 return movexy(0, px, special, kb, false, earlyret);
945 case left:
946 479 return movexy(-px, 0, special, kb, false, earlyret);
947 case right:
948 259 return movexy(px, 0, special, kb, false, earlyret);
949 case r_up:
950 return movexy(px*diagrate, -px*diagrate, special, kb, false, earlyret);
951 case r_down:
952 return movexy(px*diagrate, px*diagrate, special, kb, false, earlyret);
953 case l_up:
954 return movexy(-px*diagrate, -px*diagrate, special, kb, false, earlyret);
955 case l_down:
956 return movexy(-px*diagrate, px*diagrate, special, kb, false, earlyret);
957 }
958 return false;
959 754 }
960
961 bool enemy::moveAtAngle(zfix degrees, zfix px, int32_t special, bool kb, bool earlyret)
962 {
963 double v = degrees.getFloat() * PI / 180.0;
964 zfix dx = zc::math::Cos(v)*px, dy = zc::math::Sin(v)*px;
965 return movexy(dx, dy, special, kb, false, earlyret);
966 }
967
968 bool enemy::can_movexy(zfix dx, zfix dy, int32_t special, bool kb)
969 {
970 zfix tx = x, ty = y;
971 bool ret = movexy(dx, dy, special, kb, false, true);
972 x = tx;
973 y = ty;
974 return ret;
975 }
976 754 bool enemy::can_moveDir(int32_t dir, zfix px, int32_t special, bool kb)
977 {
978 754 zfix tx = x, ty = y;
979 754 bool ret = moveDir(dir, px, special, kb, true);
980 754 x = tx;
981 754 y = ty;
982 754 return ret;
983 }
984 bool enemy::can_moveAtAngle(zfix degrees, zfix px, int32_t special, bool kb)
985 {
986 zfix tx = x, ty = y;
987 bool ret = moveAtAngle(degrees, px, special, kb, true);
988 x = tx;
989 y = ty;
990 return ret;
991 }
992
993 // Handle pitfalls
994 37831674 bool enemy::do_falling(int32_t index)
995 {
996
2/2
✓ Branch 0 taken 37829376 times.
✓ Branch 1 taken 2298 times.
37831674 if(fallclk > 0)
997 {
998
4/4
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 2265 times.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 20 times.
2298 if(fallclk == PITFALL_FALL_FRAMES && fallCombo) sfx(combobuf[fallCombo].attribytes[0], pan(x.getInt()));
999
2/2
✓ Branch 0 taken 2276 times.
✓ Branch 1 taken 22 times.
2298 if(!--fallclk)
1000 {
1001
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
22 if(immortal) //Keep alive forever
1002 ++fallclk; //force another frame of falling.... forever.
1003
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 11 times.
22 else if(dying) //Give 1 frame for script revival
1004 {
1005
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(flags&guy_never_return)
1006 never_return(index);
1007
1008
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(leader)
1009 kill_em_all();
1010
1011 //leave_item(); //Don't drop items in pits!
1012 11 stop_bgsfx(index);
1013 11 return true;
1014 }
1015 else
1016 {
1017 11 try_death(true); //Force death
1018 11 ++fallclk; //force another frame of falling
1019 }
1020 11 }
1021
1022 2287 wpndata& spr = wpnsbuf[QMisc.sprites[sprFALL]];
1023 2287 cs = spr.csets & 0xF;
1024
1/2
✓ Branch 0 taken 2287 times.
✗ Branch 1 not taken.
2287 int32_t fr = spr.frames ? spr.frames : 1;
1025
1/2
✓ Branch 0 taken 2287 times.
✗ Branch 1 not taken.
2287 int32_t spd = spr.speed ? spr.speed : 1;
1026 2287 int32_t animclk = (PITFALL_FALL_FRAMES-fallclk);
1027
2/2
✓ Branch 0 taken 1101 times.
✓ Branch 1 taken 1186 times.
2287 tile = spr.tile + zc_min(animclk / spd, fr-1);
1028 2287 }
1029 37831663 return false;
1030 37831674 }
1031
1032 // Handle drowning in water
1033 37829376 bool enemy::do_drowning(int32_t index)
1034 {
1035
1/2
✓ Branch 0 taken 37829376 times.
✗ Branch 1 not taken.
37829376 if(drownclk > 0)
1036 {
1037 //if(drownclk == WATER_DROWN_FRAMES && drownCombo) sfx(combobuf[drownCombo].attribytes[0], pan(x.getInt()));
1038 //!TODO: Drown SFX
1039 if(!--drownclk)
1040 {
1041 if(immortal) //Keep alive forever
1042 ++drownclk; //force another frame of falling.... forever.
1043 else if(dying) //Give 1 frame for script revival
1044 {
1045 if(flags&guy_never_return)
1046 never_return(index);
1047
1048 if(leader)
1049 kill_em_all();
1050
1051 //leave_item(); //Don't drop items in pits!
1052 stop_bgsfx(index);
1053 return true;
1054 }
1055 else
1056 {
1057 try_death(true); //Force death
1058 ++drownclk; //force another frame of falling
1059 }
1060 }
1061
1062 bool lava = (drownCombo && combobuf[drownCombo].usrflags&cflag1);
1063 wpndata &spr = wpnsbuf[QMisc.sprites[lava ? sprLAVADROWN : sprDROWN]];
1064 cs = spr.csets & 0xF;
1065 int32_t fr = spr.frames ? spr.frames : 1;
1066 int32_t spd = spr.speed ? spr.speed : 1;
1067 int32_t animclk = (WATER_DROWN_FRAMES-drownclk);
1068 tile = spr.tile + zc_min((animclk % (spd*fr))/spd, fr-1);
1069 }
1070 37829376 return false;
1071 37829376 }
1072
1073 // Supplemental animation code that all derived classes should call
1074 // as a return value for animate().
1075 // Handles the death animation and returns true when enemy is finished.
1076 38493946 bool enemy::Dead(int32_t index)
1077 {
1078
2/2
✓ Branch 0 taken 1829 times.
✓ Branch 1 taken 38492117 times.
38493946 if(immortal)
1079 {
1080 1829 dying = false;
1081 1829 return false;
1082 }
1083
2/2
✓ Branch 0 taken 763293 times.
✓ Branch 1 taken 37728824 times.
38492117 if(dying)
1084 {
1085
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 763292 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
763293 if(deathexstate > -1 && deathexstate < 32)
1086 {
1087 1 setxmapflag(1<<deathexstate);
1088 1 deathexstate = -1;
1089 1 }
1090 763293 --clk2;
1091
1092
4/4
✓ Branch 0 taken 723667 times.
✓ Branch 1 taken 39626 times.
✓ Branch 2 taken 38636 times.
✓ Branch 3 taken 3210 times.
763293 if((get_qr(qr_HARDCODED_ENEMY_ANIMS) && clk2==12)
1093
2/2
✓ Branch 0 taken 41846 times.
✓ Branch 1 taken 681821 times.
723667 && hp>-1000) // not killed by ringleader
1094 38636 death_sfx();
1095
1096
2/2
✓ Branch 0 taken 719901 times.
✓ Branch 1 taken 43392 times.
763293 if(clk2==0)
1097 {
1098
2/2
✓ Branch 0 taken 42688 times.
✓ Branch 1 taken 704 times.
43392 if(flags&guy_never_return)
1099 704 never_return(index);
1100
1101
2/2
✓ Branch 0 taken 43321 times.
✓ Branch 1 taken 71 times.
43392 if(leader)
1102 71 kill_em_all();
1103
1104 43392 leave_item();
1105 43392 }
1106
1107 763293 stop_bgsfx(index);
1108 763293 return (clk2==0);
1109 }
1110
1111 37728824 return false;
1112 38493946 }
1113
1114 // Basic animation code that all derived classes should call.
1115 // The one with an index is the one that is called by
1116 // the guys sprite list; index is the enemy's index in the list.
1117 37831930 bool enemy::animate(int32_t index)
1118 {
1119
2/2
✓ Branch 0 taken 1685492 times.
✓ Branch 1 taken 36146438 times.
37831930 if(sclk <= 0) hitdir = -1;
1120
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 37831674 times.
37831930 if(switch_hooked)
1121 {
1122
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(get_qr(qr_SWITCHOBJ_RUN_SCRIPT))
1123 {
1124 //Run its script
1125 if (!didScriptThisFrame)
1126 {
1127 if (runscript_do_earlyret(run_script(MODE_NORMAL)))
1128 {
1129 return 0; //Avoid NULLPO if this object deleted itself
1130 }
1131 }
1132 }
1133 256 return false;
1134 }
1135
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 37831663 times.
37831674 if(do_falling(index)) return true;
1136
2/2
✓ Branch 0 taken 2287 times.
✓ Branch 1 taken 37829376 times.
37831663 else if(fallclk)
1137 {
1138 //clks
1139
2/2
✓ Branch 0 taken 1611 times.
✓ Branch 1 taken 676 times.
2287 if(hclk>0)
1140 676 --hclk;
1141
1/2
✓ Branch 0 taken 2287 times.
✗ Branch 1 not taken.
2287 if(stunclk>0)
1142 --stunclk;
1143
1/2
✓ Branch 0 taken 2287 times.
✗ Branch 1 not taken.
2287 if ( frozenclock > 0 )
1144 --frozenclock;
1145
1/2
✓ Branch 0 taken 2287 times.
✗ Branch 1 not taken.
2287 if(hashero)
1146 {
1147 Hero.setX(x);
1148 Hero.setY(y);
1149 Hero.fallCombo = fallCombo;
1150 Hero.fallclk = fallclk;
1151 hashero = false; //Let Hero go if falling
1152 }
1153
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2287 times.
2287 if (!didScriptThisFrame)
1154 {
1155 2287 run_script(MODE_NORMAL);
1156 2287 }
1157 2287 return false;
1158 }
1159
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37829376 times.
37829376 if(do_drowning(index)) return true;
1160
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37829376 times.
37829376 else if(drownclk)
1161 {
1162 //clks
1163 if(hclk>0)
1164 --hclk;
1165 if(stunclk>0)
1166 --stunclk;
1167 if ( frozenclock > 0 )
1168 --frozenclock;
1169 if(hashero)
1170 {
1171 Hero.setX(x);
1172 Hero.setY(y);
1173 Hero.drownclk = drownclk;
1174 hashero = false; //Let Hero go if falling
1175 }
1176 if (!didScriptThisFrame)
1177 {
1178 run_script(MODE_NORMAL);
1179 }
1180 return false;
1181 }
1182 37829376 int32_t nx = real_x(x);
1183 37829376 int32_t ny = real_y(y);
1184
1185
4/4
✓ Branch 0 taken 27361185 times.
✓ Branch 1 taken 10468191 times.
✓ Branch 2 taken 5643749 times.
✓ Branch 3 taken 21717436 times.
37829376 if(ox!=nx || oy!=ny)
1186 {
1187 16111940 posframe=(posframe+1)%(get_qr(qr_NEWENEMYTILES)?4:2);
1188 16111940 }
1189
1190 37829376 ox = nx;
1191 37829376 oy = ny;
1192
1193 // Maybe they fell off the bottom in sideview, or were moved by a script.
1194
1195 //Check offscreen settings. I wrote it this way for clarity and to simplify testing. -Z
1196
2/2
✓ Branch 0 taken 1829 times.
✓ Branch 1 taken 37827547 times.
37829376 if ( immortal )
1197 {
1198 //skip, as it can go out of bounds, from immortality
1199 1829 }
1200
2/6
✓ Branch 0 taken 37827547 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 37827547 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
37827547 else if ( (moveflags & move_ignore_screenedge) || (( (get_qr(qr_OUTOFBOUNDSENEMIES)) != bool(editorflags&ENEMY_FLAG11) ) && !NEWOUTOFBOUNDS(x,y,z+fakez)) )
1201 {
1202 //skip, it can go out of bounds, from a quest rule, or from the enemy editor (but not both!)
1203 }
1204
9/10
✓ Branch 0 taken 37431454 times.
✓ Branch 1 taken 396093 times.
✓ Branch 2 taken 37826542 times.
✓ Branch 3 taken 1005 times.
✓ Branch 4 taken 37796252 times.
✓ Branch 5 taken 30290 times.
✓ Branch 6 taken 37796252 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 51 times.
✓ Branch 9 taken 37796201 times.
37827547 else if ( (OUTOFBOUNDS) )
1205 {
1206 31346 hp=-1000; //kill it, as it is not immortal, and no quest bit or rule is enabled
1207 31346 }
1208 //fall down
1209
6/6
✓ Branch 0 taken 27137055 times.
✓ Branch 1 taken 10692321 times.
✓ Branch 2 taken 10424771 times.
✓ Branch 3 taken 27404605 times.
✓ Branch 4 taken 506547 times.
✓ Branch 5 taken 9918224 times.
37829376 if((enemycanfall(id) || (moveflags & move_obeys_grav) )&& fading != fade_flicker && clk>=0)
1210 {
1211
2/2
✓ Branch 0 taken 303574 times.
✓ Branch 1 taken 9614650 times.
9918224 if(isSideViewGravity())
1212 {
1213
1/2
✓ Branch 0 taken 303574 times.
✗ Branch 1 not taken.
303574 if(get_qr(qr_OLD_SIDEVIEW_LANDING_CODE))
1214 {
1215
2/2
✓ Branch 0 taken 176339 times.
✓ Branch 1 taken 127235 times.
303574 if(!isOnSideviewPlatform())
1216 {
1217 127235 bool willHitSVPlatform = false;
1218
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127235 times.
127235 int32_t usewid = (SIZEflags&OVERRIDE_HIT_WIDTH)?hit_width:16;
1219
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127235 times.
127235 int32_t usehei = (SIZEflags&OVERRIDE_HIT_HEIGHT)?hit_height:16;
1220
2/2
✓ Branch 0 taken 127235 times.
✓ Branch 1 taken 127235 times.
254470 for(int32_t nx = x+4; nx < x+usewid; nx+=16)
1221 {
1222
5/8
✓ Branch 0 taken 23361 times.
✓ Branch 1 taken 103874 times.
✓ Branch 2 taken 23361 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 23361 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 127235 times.
✗ Branch 7 not taken.
127235 if(fall > 0 && !IGNORE_SIDEVIEW_PLATFORMS && checkSVLadderPlatform(x+4,y+(fall/100)+usehei-1) && (((int32_t(y)+(int32_t(fall)/100)+usehei-1)&0xF0)!=((int32_t(y)+usehei-1)&0xF0)))
1223 {
1224 willHitSVPlatform = true;
1225 break;
1226 }
1227 127235 }
1228
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127235 times.
127235 if(willHitSVPlatform)
1229 {
1230 y+=fall/100;
1231 //y-=int32_t(y)%16; //Fix to top of SV Ladder
1232 do_fix(y, 16); //Fix to top of SV Ladder
1233 fall = 0;
1234 }
1235 else
1236 {
1237 127235 y+=fall/100;
1238
2/2
✓ Branch 0 taken 17808 times.
✓ Branch 1 taken 109427 times.
127235 if(fall <= (int32_t)zinit.terminalv)
1239 109427 fall += (zinit.gravity/100);
1240 }
1241 127235 }
1242 else
1243 {
1244
2/2
✓ Branch 0 taken 267 times.
✓ Branch 1 taken 176072 times.
176339 if(fall!=0) // Only fix pos once
1245 {
1246 //y-=(int32_t)y%8; // Fix position
1247 267 do_fix(y, 8); //Fix position
1248 267 }
1249
1250 176339 fall = 0;
1251 }
1252 303574 }
1253 else
1254 {
1255 if(isOnSideviewPlatform())
1256 fall = 0;
1257 else
1258 {
1259 zfix fall_amnt = fall/100;
1260 bool hit = false;
1261 while(fall_amnt >= 1)
1262 {
1263 --fall_amnt;
1264 ++y;
1265 if(isOnSideviewPlatform())
1266 {
1267 y = y.getInt();
1268 fall_amnt = 0;
1269 hit = true;
1270 break;
1271 }
1272 }
1273 if(fall_amnt > 0)
1274 y += fall_amnt;
1275 if(fall_amnt < 0)
1276 {
1277 if(!movexy(0,fall_amnt,spw_none,false,!get_qr(qr_BROKEN_SIDEVIEW_SPRITE_JUMP)))
1278 hit = true;
1279 }
1280 if(hit)
1281 fall = 0;
1282 else if(fall <= (int32_t)zinit.terminalv)
1283 fall += (zinit.gravity/100);
1284 }
1285 }
1286 303574 }
1287 else
1288 {
1289
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9614650 times.
9614650 if (!(moveflags & move_no_fake_z))
1290 {
1291
2/2
✓ Branch 0 taken 5060446 times.
✓ Branch 1 taken 4554204 times.
9614650 if(fakefall!=0)
1292 4554204 fakez-=(fakefall/100);
1293
1294
2/2
✓ Branch 0 taken 4554204 times.
✓ Branch 1 taken 5060446 times.
9614650 if(fakez<0)
1295 4554204 fakez = fakefall = 0;
1296
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5060446 times.
5060446 else if(fakefall <= (int32_t)zinit.terminalv)
1297 5060446 fakefall += (zinit.gravity/100);
1298
1299
5/6
✓ Branch 0 taken 9614650 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5060446 times.
✓ Branch 3 taken 4554204 times.
✓ Branch 4 taken 4568446 times.
✓ Branch 5 taken 492000 times.
9614650 if (fakez<=0 && fakefall > 0 && !get_qr(qr_FLUCTUATING_ENEMY_JUMP)) fakefall = 0;
1300 9614650 }
1301
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9614650 times.
9614650 if (!(moveflags & move_no_real_z))
1302 {
1303
2/2
✓ Branch 0 taken 5482595 times.
✓ Branch 1 taken 4132055 times.
9614650 if(fall!=0)
1304 4132055 z-=(fall/100);
1305
1306
2/2
✓ Branch 0 taken 4118773 times.
✓ Branch 1 taken 5495877 times.
9614650 if(z<0)
1307 4118773 z = fall = 0;
1308
2/2
✓ Branch 0 taken 9167 times.
✓ Branch 1 taken 5486710 times.
5495877 else if(fall <= (int32_t)zinit.terminalv)
1309 5486710 fall += (zinit.gravity/100);
1310
1311
6/6
✓ Branch 0 taken 9573746 times.
✓ Branch 1 taken 40904 times.
✓ Branch 2 taken 5454973 times.
✓ Branch 3 taken 4118773 times.
✓ Branch 4 taken 4964780 times.
✓ Branch 5 taken 490193 times.
9614650 if (z<=0 && fall > 0 && !get_qr(qr_FLUCTUATING_ENEMY_JUMP)) fall = 0;
1312 9614650 }
1313
1314 }
1315 9918224 }
1316
4/4
✓ Branch 0 taken 37433283 times.
✓ Branch 1 taken 396093 times.
✓ Branch 2 taken 9198621 times.
✓ Branch 3 taken 28234662 times.
37829376 if(!isSideViewGravity() && (moveflags & move_can_pitfall))
1317 {
1318
8/10
✓ Branch 0 taken 9172101 times.
✓ Branch 1 taken 26520 times.
✓ Branch 2 taken 9132443 times.
✓ Branch 3 taken 39658 times.
✓ Branch 4 taken 9132443 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 9172101 times.
✓ Branch 8 taken 9132443 times.
✓ Branch 9 taken 9132443 times.
9198621 if(can_pitfall() && ((z <= 0 && fakez <= 0 && !isflier(id)) || (isflier(id) && (stunclk))) && !superman)
1319 {
1320 9132443 fallCombo = check_pits();
1321 9132443 }
1322 27463507 }
1323
4/4
✓ Branch 0 taken 37433283 times.
✓ Branch 1 taken 18660979 times.
✓ Branch 2 taken 146615 times.
✓ Branch 3 taken 37286668 times.
56094262 if(!isSideViewGravity() && (moveflags & move_can_waterdrown))
1324 {
1325
8/10
✓ Branch 0 taken 142669 times.
✓ Branch 1 taken 3946 times.
✓ Branch 2 taken 141616 times.
✓ Branch 3 taken 1053 times.
✓ Branch 4 taken 141616 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 142669 times.
✓ Branch 8 taken 141616 times.
✓ Branch 9 taken 141616 times.
146615 if(can_pitfall() && ((z <= 0 && fakez <= 0 && !isflier(id)) || (isflier(id) && (stunclk))) && !superman)
1326 {
1327 141616 drownCombo = check_water();
1328 141616 }
1329 429847 }
1330
1331 56377494 runKnockback(); //scripted knockback handling
1332
1333 // clk is incremented here
1334
2/2
✓ Branch 0 taken 54072787 times.
✓ Branch 1 taken 2304707 times.
56377494 if(++clk >= frate)
1335 2304707 clk=0;
1336
1337 // hit and death handling
1338
2/2
✓ Branch 0 taken 1240565 times.
✓ Branch 1 taken 55136929 times.
56377494 if(hclk>0)
1339 1240565 --hclk;
1340
1341
2/2
✓ Branch 0 taken 676239 times.
✓ Branch 1 taken 55701255 times.
56377494 if(stunclk>0)
1342 676239 --stunclk;
1343
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56377494 times.
56377494 if ( frozenclock > 0 )
1344 --frozenclock;
1345
1346
5/6
✓ Branch 0 taken 13488 times.
✓ Branch 1 taken 56364006 times.
✓ Branch 2 taken 106 times.
✓ Branch 3 taken 13382 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 106 times.
56377494 if(ceiling && z <= 0 && fakez <= 0)
1347 106 ceiling = false;
1348
1349 56377494 try_death();
1350
1351 56377494 scored=false;
1352
1353 56377494 ++c_clk;
1354
1355 //Run its script
1356
2/2
✓ Branch 0 taken 18572935 times.
✓ Branch 1 taken 37804559 times.
56377494 if (!didScriptThisFrame)
1357 {
1358
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37804559 times.
37804559 if (runscript_do_earlyret(run_script(MODE_NORMAL)))
1359 {
1360 return 0; //Avoid NULLPO if this object deleted itself
1361 }
1362 37804559 }
1363
1364 // returns true when enemy is defeated
1365 56377494 return Dead(index);
1366 56380048 }
1367
1368 38581572 bool enemy::setSolid(bool set)
1369 {
1370
1/2
✓ Branch 0 taken 38581572 times.
✗ Branch 1 not taken.
38581572 bool actual = set && !isSubmerged();
1371 38581572 bool ret = solid_object::setSolid(actual);
1372 38581572 solid = set;
1373 38581572 return ret;
1374 }
1375 void enemy::doContactDamage(int32_t hdir)
1376 {
1377 Hero.hithero(guys.find(this), hdir);
1378 }
1379
1380 22405 void enemy::solid_push(solid_object *obj)
1381 {
1382
1/2
✓ Branch 0 taken 22405 times.
✗ Branch 1 not taken.
22405 if(obj == this) return; //can't push self
1383
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22405 times.
22405 if(moveflags&move_not_pushable) return; //not pushable
1384 22405 zfix dx, dy;
1385 22405 int32_t hdir = -1;
1386 22405 solid_push_int(obj,dx,dy,hdir,true);
1387
1388
4/4
✓ Branch 0 taken 22292 times.
✓ Branch 1 taken 113 times.
✓ Branch 2 taken 150 times.
✓ Branch 3 taken 22142 times.
22405 if(!dx && !dy) return;
1389
1390 263 bool t = obj->getTempNonsolid();
1391 263 obj->setTempNonsolid(true);
1392
1393 263 int32_t ydir = dy > 0 ? down : up;
1394 263 int32_t xdir = dx > 0 ? right : left;
1395
1396 263 auto special = isflier(id) ? spw_floater : spw_none;
1397
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 7 times.
263 if(!movexy(dx,dy,special,true,true))
1398 {
1399 //Crushed?
1400 7 }
1401
1402 263 obj->setTempNonsolid(t);
1403 22405 }
1404 22405 bool enemy::is_unpushable() const
1405 {
1406 22405 return isSubmerged();
1407 }
1408 22087 bool enemy::sideview_mode() const
1409 {
1410
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 22087 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
22087 return isSideViewGravity() && (moveflags&move_obeys_grav) && !(moveflags&move_not_pushable);
1411 }
1412
1413 3234 bool enemy::m_walkflag_old(int32_t dx,int32_t dy,int32_t special, int32_t x, int32_t y)
1414 {
1415 3234 int32_t yg = (special==spw_floater)?8:0;
1416 3234 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
1417
1418
8/10
✓ Branch 0 taken 2364 times.
✓ Branch 1 taken 870 times.
✓ Branch 2 taken 814 times.
✓ Branch 3 taken 56 times.
✓ Branch 4 taken 870 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 870 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2368 times.
✓ Branch 9 taken 3238 times.
3234 if(dx<16-nb || dy<zc_max(16-yg-nb,0) || dx>=240+nb || dy>=160+nb)
1419 4732 return true;
1420
1421 3238 bool isInDungeon = isdungeon();
1422
3/4
✓ Branch 0 taken 262 times.
✓ Branch 1 taken 2976 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 262 times.
3238 if(isInDungeon || special==spw_wizzrobe)
1423 {
1424
7/8
✓ Branch 0 taken 601 times.
✓ Branch 1 taken 2375 times.
✓ Branch 2 taken 595 times.
✓ Branch 3 taken 8 times.
✓ Branch 4 taken 604 times.
✓ Branch 5 taken 1779 times.
✓ Branch 6 taken 604 times.
✗ Branch 7 not taken.
2976 if((x>=32 && dy<32-yg) || (y>-1000 && y<=144 && dy>=144))
1425 1199 return true;
1426
1427
7/8
✓ Branch 0 taken 592 times.
✓ Branch 1 taken 1187 times.
✓ Branch 2 taken 595 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 595 times.
✓ Branch 5 taken 595 times.
✓ Branch 6 taken 595 times.
✗ Branch 7 not taken.
1779 if((x>=32 && dx<32) || (x>-1000 && x<224 && dx>=224))
1428
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
1190 if(special!=spw_door) // walk in door way
1429 return true;
1430 595 }
1431
1432
3/4
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 795 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
857 if(!(moveflags & move_can_pitwalk) && !(moveflags & move_can_pitfall)) //Don't walk into pits (knockback doesn't call this func)
1433 {
1434
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
124 if(ispitfall(dx,dy) || ispitfall(dx+8,dy)
1435
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
62 || ispitfall(dx,dy+8) || ispitfall(dx+8,dy+8))
1436 return true;
1437 62 }
1438
1439
1/4
✓ Branch 0 taken 857 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
857 switch(special)
1440 {
1441 case spw_clipbottomright:
1442 if(dy>=128 || dx>=208) return true;
1443 break;
1444 case spw_clipright:
1445 break; //if(x>=208) return true; break;
1446
1447 case spw_wizzrobe: // fall through
1448 case spw_floater: // Special case for fliers and wizzrobes - hack!
1449 {
1450
2/2
✓ Branch 0 taken 262 times.
✓ Branch 1 taken 595 times.
857 if(isInDungeon)
1451 {
1452
2/4
✓ Branch 0 taken 595 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 595 times.
595 if(dy < 32-yg || dy >= 144) return true;
1453
2/4
✓ Branch 0 taken 595 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 595 times.
595 if(dx < 32 || dx >= 224) return true;
1454 595 }
1455 857 return false;
1456 }
1457 }
1458
1459 dx&=(special==spw_halfstep)?(~7):(~15);
1460 dy&=(special==spw_halfstep || isSideViewGravity())?(~7):(~15);
1461
1462 if(special==spw_water)
1463 return (water_walkflag(dx,dy+8,1) || water_walkflag(dx+8,dy+8,1));
1464
1465 return _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1466 groundblocked(dx,dy+8) || groundblocked(dx+8,dy+8);
1467 870 }
1468
1469 6575 bool enemy::m_walkflag_simple(int32_t dx,int32_t dy)
1470 {
1471 6575 bool kb = false;
1472 6575 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
1473
1474
5/10
✗ Branch 0 not taken.
✓ Branch 1 taken 6575 times.
✓ Branch 2 taken 6575 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6575 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6575 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 6575 times.
6575 if(dx<16-nb || dy<zc_max(16-nb,0) || dx>=240+nb || dy>=160+nb)
1475 return true;
1476
1477
2/2
✓ Branch 0 taken 5062 times.
✓ Branch 1 taken 1513 times.
6575 if(isdungeon())
1478 {
1479
2/4
✓ Branch 0 taken 1513 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1513 times.
1513 if((dy<32) || (dy>=144))
1480 return true;
1481
1482
2/4
✓ Branch 0 taken 1513 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1513 times.
1513 if((dx<32) || (dx>=224))
1483 return true;
1484 1513 }
1485
1486
2/4
✓ Branch 0 taken 6575 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6575 times.
6575 if(!(moveflags & move_can_pitwalk) && (!(moveflags & move_can_pitfall))) //Don't walk into pits, unless being knocked back
1487 {
1488
2/4
✓ Branch 0 taken 6575 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6575 times.
13150 if(ispitfall(dx,dy) || ispitfall(dx+8,dy)
1489
2/4
✓ Branch 0 taken 6575 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6575 times.
✗ Branch 3 not taken.
6575 || ispitfall(dx,dy+8) || ispitfall(dx+8,dy+8))
1490 return true;
1491 6575 }
1492
1493
2/2
✓ Branch 0 taken 6545 times.
✓ Branch 1 taken 30 times.
6575 if(get_qr(qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY))
1494 {
1495
3/4
✓ Branch 0 taken 2657 times.
✓ Branch 1 taken 3888 times.
✓ Branch 2 taken 2657 times.
✗ Branch 3 not taken.
9202 return _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1496
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2657 times.
2657 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1497 }
1498 else
1499 {
1500
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
60 return _walkflag(dx,dy,1) || _walkflag(dx+8,dy,1) ||
1501
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1502
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 groundblocked(dx,dy,kb) || groundblocked(dx+8,dy,kb) ||
1503
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1504 }
1505 6575 }
1506
1507 32455581 bool enemy::m_walkflag(int32_t dx,int32_t dy,int32_t special, int32_t dir, int32_t input_x, int32_t input_y, bool kb)
1508 {
1509
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32455581 times.
32455581 if(moveflags & move_new_movement)
1510 return scr_walkflag(dx,dy,special,dir,input_x,input_y,kb);
1511 32455581 int32_t yg = (special==spw_floater)?8:0;
1512 32455581 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
1513
2/2
✓ Branch 0 taken 3703969 times.
✓ Branch 1 taken 28751612 times.
32455581 switch(dir)
1514 {
1515 case l_down:
1516 case r_down:
1517 case down:
1518 case 11: //r_down
1519 case 12: //down
1520 case 13: //l_down
1521 {
1522
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3703969 times.
3703969 if ( ((unsigned)(id&0xFFF)) < MAXGUYS )
1523 {
1524
3/4
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 3703961 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
3703969 if ( SIZEflags&OVERRIDE_HIT_HEIGHT && !isflier(id) )
1525 {
1526 //Small enemies are treated as 16x16, for the purposes of m_walkflag!
1527
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 dy += zc_max(hit_height-16,0);
1528 8 }
1529 3703969 }
1530 3703969 break;
1531 }
1532 }
1533
2/2
✓ Branch 0 taken 3704751 times.
✓ Branch 1 taken 28750830 times.
32455581 switch(dir)
1534 {
1535 case r_up:
1536 case r_down:
1537 case right:
1538 case 9: //r_up
1539 case 10: //right
1540 case 11: //r_down
1541 {
1542
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3704751 times.
3704751 if ( ((unsigned)(id&0xFFF)) < MAXGUYS )
1543 {
1544
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3704748 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
3704751 if ( SIZEflags&OVERRIDE_HIT_WIDTH && !isflier(id) )
1545 {
1546 //Small enemies are treated as 16x16, for the purposes of m_walkflag!
1547
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 dx += zc_max(hit_width-16,0);
1548 3 }
1549 3704751 }
1550 3704751 break;
1551 }
1552 }
1553 //Z_eventlog("Checking x,y %d,%d\n",dx,dy);
1554
1555
10/10
✓ Branch 0 taken 22401614 times.
✓ Branch 1 taken 10053967 times.
✓ Branch 2 taken 8752349 times.
✓ Branch 3 taken 1301618 times.
✓ Branch 4 taken 10016888 times.
✓ Branch 5 taken 37079 times.
✓ Branch 6 taken 9993761 times.
✓ Branch 7 taken 23127 times.
✓ Branch 8 taken 22454486 times.
✓ Branch 9 taken 32448247 times.
32455581 if(dx<16-nb || dy<zc_max(16-yg-nb,0) || dx>=240+nb || dy>=160+nb)
1556 44916306 return true;
1557
1558 32448247 bool isInDungeon = isdungeon();
1559
4/4
✓ Branch 0 taken 3927116 times.
✓ Branch 1 taken 28521131 times.
✓ Branch 2 taken 11756 times.
✓ Branch 3 taken 3915360 times.
32448247 if(isInDungeon || special==spw_wizzrobe)
1560 {
1561
8/8
✓ Branch 0 taken 5892066 times.
✓ Branch 1 taken 22640821 times.
✓ Branch 2 taken 5667599 times.
✓ Branch 3 taken 224467 times.
✓ Branch 4 taken 5820182 times.
✓ Branch 5 taken 17045106 times.
✓ Branch 6 taken 5819995 times.
✓ Branch 7 taken 187 times.
28532887 if((input_x>=32 && dy<32-yg) || (input_y>-1000 && input_y<=144 && dy>=144))
1562 11487594 return true;
1563
1564
8/8
✓ Branch 0 taken 5739703 times.
✓ Branch 1 taken 11305590 times.
✓ Branch 2 taken 5573250 times.
✓ Branch 3 taken 166453 times.
✓ Branch 4 taken 5688164 times.
✓ Branch 5 taken 5783879 times.
✓ Branch 6 taken 5687210 times.
✓ Branch 7 taken 954 times.
17045293 if((input_x>=32 && dx<32) || (input_x>-1000 && input_x<224 && dx>=224))
1565
2/2
✓ Branch 0 taken 113866 times.
✓ Branch 1 taken 94 times.
11260460 if(special!=spw_door) // walk in door way
1566 113866 return true;
1567 5784927 }
1568
1569
6/6
✓ Branch 0 taken 3100321 times.
✓ Branch 1 taken 6599966 times.
✓ Branch 2 taken 750009 times.
✓ Branch 3 taken 2350312 times.
✓ Branch 4 taken 51230 times.
✓ Branch 5 taken 698779 times.
9700287 if(!(moveflags & move_can_pitwalk) && (!(moveflags & move_can_pitfall) || !kb)) //Don't walk into pits, unless being knocked back
1570 {
1571
4/4
✓ Branch 0 taken 3042674 times.
✓ Branch 1 taken 6417 times.
✓ Branch 2 taken 50 times.
✓ Branch 3 taken 3041722 times.
6090863 if(ispitfall(dx,dy) || ispitfall(dx+8,dy)
1572
4/4
✓ Branch 0 taken 3042491 times.
✓ Branch 1 taken 183 times.
✓ Branch 2 taken 3041772 times.
✓ Branch 3 taken 719 times.
3042674 || ispitfall(dx,dy+8) || ispitfall(dx+8,dy+8))
1573 7369 return true;
1574 3041722 }
1575
1576
4/4
✓ Branch 0 taken 7508153 times.
✓ Branch 1 taken 2178511 times.
✓ Branch 2 taken 973 times.
✓ Branch 3 taken 5281 times.
9692918 switch(special)
1577 {
1578 case spw_clipbottomright:
1579
4/4
✓ Branch 0 taken 786 times.
✓ Branch 1 taken 187 times.
✓ Branch 2 taken 79 times.
✓ Branch 3 taken 707 times.
973 if(dy>=128 || dx>=208) return true;
1580 707 break;
1581 case spw_clipright:
1582 5281 break; //if(input_x>=208) return true; break;
1583
1584 case spw_wizzrobe: // fall through
1585 case spw_floater: // Special case for fliers and wizzrobes - hack!
1586 {
1587
2/2
✓ Branch 0 taken 2866474 times.
✓ Branch 1 taken 4641679 times.
7508153 if(isInDungeon)
1588 {
1589
3/4
✓ Branch 0 taken 4641667 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4641667 times.
4641679 if(dy < 32-yg || dy >= 144) return true;
1590
4/4
✓ Branch 0 taken 4639555 times.
✓ Branch 1 taken 2112 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 4639539 times.
4641667 if(dx < 32 || dx >= 224) return true;
1591 4639539 }
1592 7506013 return false;
1593 }
1594 }
1595
1596 2184499 dx&=(special==spw_halfstep)?(~7):(~15);
1597
2/2
✓ Branch 0 taken 486587 times.
✓ Branch 1 taken 1697912 times.
2184499 dy&=(special==spw_halfstep || isSideViewGravity())?(~7):(~15);
1598
1599
2/2
✓ Branch 0 taken 414391 times.
✓ Branch 1 taken 1770108 times.
2184499 if(special==spw_water)
1600
2/2
✓ Branch 0 taken 16741 times.
✓ Branch 1 taken 397650 times.
414391 return (water_walkflag(dx,dy+8,1) || water_walkflag(dx+8,dy+8,1));
1601
1602
2/2
✓ Branch 0 taken 1711234 times.
✓ Branch 1 taken 58874 times.
1770108 if(get_qr(qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY))
1603 {
1604
4/4
✓ Branch 0 taken 1227843 times.
✓ Branch 1 taken 483391 times.
✓ Branch 2 taken 1217806 times.
✓ Branch 3 taken 10037 times.
2929040 return _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1605
2/2
✓ Branch 0 taken 14580 times.
✓ Branch 1 taken 1203226 times.
1217806 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1606 }
1607 else
1608 {
1609
4/4
✓ Branch 0 taken 42381 times.
✓ Branch 1 taken 16493 times.
✓ Branch 2 taken 42117 times.
✓ Branch 3 taken 264 times.
100991 return _walkflag(dx,dy,1) || _walkflag(dx+8,dy,1) ||
1610
3/4
✓ Branch 0 taken 41754 times.
✓ Branch 1 taken 363 times.
✓ Branch 2 taken 41754 times.
✗ Branch 3 not taken.
42117 _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1611
4/4
✓ Branch 0 taken 36519 times.
✓ Branch 1 taken 5235 times.
✓ Branch 2 taken 36504 times.
✓ Branch 3 taken 15 times.
41754 groundblocked(dx,dy,kb) || groundblocked(dx+8,dy,kb) ||
1612
2/2
✓ Branch 0 taken 36201 times.
✓ Branch 1 taken 303 times.
36504 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1613 }
1614 10079627 }
1615
1616 383430 bool enemy::isOnSideviewPlatform()
1617 {
1618
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 383430 times.
383430 int32_t usewid = (SIZEflags&OVERRIDE_HIT_WIDTH) ? hit_width : 16;
1619
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 383430 times.
383430 int32_t usehei = (SIZEflags&OVERRIDE_HIT_HEIGHT) ? hit_height : 16;
1620
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 383430 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
383430 if(!get_qr(qr_BROKEN_SIDEVIEW_SPRITE_JUMP)&&fall<0)
1621 return false;
1622
5/6
✓ Branch 0 taken 10306 times.
✓ Branch 1 taken 373124 times.
✓ Branch 2 taken 211 times.
✓ Branch 3 taken 10095 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 211 times.
383430 if(y + usehei >= 176 && currscr>=0x70 && !(tmpscr->flags2&wfDOWN)) return true; //Bottom of the map
1623
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 383219 times.
383219 if(check_slope(x, y+1, usewid, usehei)) return true;
1624
2/2
✓ Branch 0 taken 383219 times.
✓ Branch 1 taken 168001 times.
551220 for(int32_t nx = x + 4; nx <= x + usewid - 4; nx+=16)
1625 {
1626
2/2
✓ Branch 0 taken 168001 times.
✓ Branch 1 taken 215218 times.
383219 if(_walkflag(nx,y+usehei,1)) return true;
1627
3/4
✓ Branch 0 taken 168001 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 120644 times.
✓ Branch 3 taken 47357 times.
168001 if(IGNORE_SIDEVIEW_PLATFORMS || ((int32_t(y)+usehei)%16)!=0) continue;
1628
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 47357 times.
47357 if(checkSVLadderPlatform(nx,y+usehei)) return true;
1629 47357 }
1630 168001 return false;
1631 383430 }
1632
1633 // Stops playing the given sound only if there are no enemies left to play it
1634 766204 void enemy::stop_bgsfx(int32_t index)
1635 {
1636
2/2
✓ Branch 0 taken 751094 times.
✓ Branch 1 taken 15110 times.
766204 if(bgsfx<=0)
1637 751094 return;
1638
1639 // Look for other enemies with the same bgsfx
1640
2/2
✓ Branch 0 taken 52994 times.
✓ Branch 1 taken 8806 times.
61800 for(int32_t i=0; i<guys.Count(); i++)
1641 {
1642
4/4
✓ Branch 0 taken 41902 times.
✓ Branch 1 taken 11092 times.
✓ Branch 2 taken 6304 times.
✓ Branch 3 taken 35598 times.
52994 if(i!=index && ((enemy*)guys.spr(i))->bgsfx==bgsfx)
1643 6304 return;
1644 46690 }
1645
1646 8806 stop_sfx(bgsfx);
1647 766204 }
1648
1649
1650 // to allow for different sfx on defeating enemy
1651 40244 void enemy::death_sfx()
1652 {
1653
2/2
✓ Branch 0 taken 39960 times.
✓ Branch 1 taken 284 times.
40244 if(deadsfx > 0) sfx(deadsfx,pan(int32_t(x)));
1654 40244 }
1655
1656 void enemy::move(zfix dx,zfix dy)
1657 {
1658 /*if(FFCore.getQuestHeaderInfo(vZelda) >= 0x255 && FFCore.getQuestHeaderInfo(vBuild) >= 50 )
1659 {
1660 switch(family)
1661 {
1662 case eeFIRE:
1663 case eeOTHER:
1664 return;
1665 default: break;
1666 }
1667 if(family >= eeSCRIPT01 && family <= eeFFRIENDLY10 ) return;
1668 }
1669 */
1670 if(!watch && (!(isSideViewGravity()) || isOnSideviewPlatform() || !(moveflags & move_obeys_grav) || !enemycanfall(id)))
1671 {
1672 x+=dx;
1673 y+=dy;
1674 }
1675 }
1676
1677 18327917 void enemy::move(zfix s)
1678 {
1679 /*if(FFCore.getQuestHeaderInfo(vZelda) >= 0x255 && FFCore.getQuestHeaderInfo(vBuild) >= 50 )
1680 {
1681 switch(family)
1682 {
1683 case eeFIRE:
1684 case eeOTHER:
1685 return;
1686 default: break;
1687 }
1688 if(family >= eeSCRIPT01 && family <= eeFFRIENDLY10 ) return;
1689 }*/
1690
9/10
✓ Branch 0 taken 18327878 times.
✓ Branch 1 taken 39 times.
✓ Branch 2 taken 79762 times.
✓ Branch 3 taken 18248116 times.
✓ Branch 4 taken 40724 times.
✓ Branch 5 taken 39038 times.
✓ Branch 6 taken 855 times.
✓ Branch 7 taken 39869 times.
✓ Branch 8 taken 855 times.
✗ Branch 9 not taken.
18327917 if(!watch && (!(isSideViewGravity()) || isOnSideviewPlatform() || !enemycanfall(id) || !(moveflags & move_obeys_grav)))
1691 {
1692 18327023 sprite::move(s);
1693 18327023 }
1694 18327917 }
1695
1696 43694 void enemy::leave_item()
1697 {
1698 43694 int32_t drop_item = select_dropitem(item_set, x, y);
1699 43694 int32_t thedropset = item_set;
1700
1701 43694 std::vector<int32_t> &ev = FFCore.eventData;
1702 43694 ev.clear();
1703 43694 ev.push_back(getUID());
1704 43694 ev.push_back(drop_item*10000);
1705 43694 ev.push_back(thedropset*10000);
1706
1707 43694 throwGenScriptEvent(GENSCR_EVENT_ENEMY_DROP_ITEM_1);
1708 43694 drop_item = vbound(ev[1] / 10000,-2,255);
1709 43694 thedropset = ev[2] / 10000;
1710 43694 ev.clear();
1711
1/2
✓ Branch 0 taken 43694 times.
✗ Branch 1 not taken.
43694 if(drop_item == -2)
1712 {
1713 drop_item = select_dropitem(thedropset,x,y);
1714 }
1715
1716
6/6
✓ Branch 0 taken 16429 times.
✓ Branch 1 taken 27265 times.
✓ Branch 2 taken 917 times.
✓ Branch 3 taken 15512 times.
✓ Branch 4 taken 169 times.
✓ Branch 5 taken 748 times.
43694 if(drop_item>=0&&((itemsbuf[drop_item].family!=itype_fairy)||!m_walkflag(x,y,0,dir)))
1717 {
1718 item* itm;
1719
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16260 times.
16260 if (get_qr(qr_ENEMY_DROPS_USE_HITOFFSETS))
1720 {
1721 itm = (new item(x+hxofs+(hit_width/2)-8,y+hyofs+(hit_height/2)-8,(zfix)0,drop_item,ipBIGRANGE+ipTIMER,0));
1722 }
1723 else
1724 {
1725
8/14
✓ Branch 0 taken 1629 times.
✓ Branch 1 taken 14631 times.
✓ Branch 2 taken 1629 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1629 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1629 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1629 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1629 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1629 times.
✗ Branch 13 not taken.
16260 if(extend >= 3) itm = (new item(x+(txsz-1)*8,y+(tysz-1)*8,(zfix)0,drop_item,ipBIGRANGE+ipTIMER,0));
1726
4/8
✓ Branch 0 taken 14631 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14631 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14631 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 14631 times.
✗ Branch 7 not taken.
14631 else itm = (new item(x,y,(zfix)0,drop_item,ipBIGRANGE+ipTIMER,0));
1727 }
1728 16260 itm->from_dropset = thedropset;
1729 16260 items.add(itm);
1730
1731 16260 ev.push_back(getUID());
1732 16260 ev.push_back(itm->getUID());
1733
1734 16260 throwGenScriptEvent(GENSCR_EVENT_ENEMY_DROP_ITEM_2);
1735 16260 ev.clear();
1736 16260 }
1737 43694 }
1738
1739 // auomatically kill off enemy (for rooms with ringleaders)
1740 397 void enemy::kickbucket()
1741 {
1742
3/4
✓ Branch 0 taken 365 times.
✓ Branch 1 taken 32 times.
✓ Branch 2 taken 365 times.
✗ Branch 3 not taken.
397 if(!superman && !(flags&guy_ignore_kill_all))
1743 365 hp=-1000; // don't call death_sfx()
1744 397 }
1745
1746 21250 bool enemy::isSubmerged() const
1747 {
1748 21250 return submerged;
1749 //!TODO SOLIDPUSH more things like teleporting wizzrobes
1750 }
1751
1752 20952 void enemy::FireBreath(bool seekhero)
1753 {
1754
1/2
✓ Branch 0 taken 20952 times.
✗ Branch 1 not taken.
20952 if(wpn==wNone)
1755 return;
1756
1757
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20952 times.
20952 if(wpn==ewFireTrail)
1758 {
1759 dmisc1 = e1tEACHTILE;
1760 FireWeapon();
1761 return;
1762 }
1763
1764 20952 float fire_angle=0.0;
1765 20952 int32_t wx=0, wy=0, wdir=dir, xoff=0, yoff=0;
1766
1767
1/2
✓ Branch 0 taken 20952 times.
✗ Branch 1 not taken.
20952 if (SIZEflags & OVERRIDE_HIT_WIDTH)
1768 {
1769 xoff += hxofs;
1770 if (weapoverrideFLAGS & OVERRIDE_HIT_WIDTH)
1771 xoff += (hit_width / 2) - (weap_tilew * 8);
1772 else
1773 xoff += (hit_width / 2) - 8;
1774 }
1775
1/2
✓ Branch 0 taken 20952 times.
✗ Branch 1 not taken.
20952 if (SIZEflags & OVERRIDE_HIT_HEIGHT)
1776 {
1777 yoff += hyofs;
1778 if (weapoverrideFLAGS & OVERRIDE_HIT_HEIGHT)
1779 yoff += (hit_height / 2) - (weap_tileh * 8);
1780 else
1781 yoff += (hit_height / 2) - 8;
1782 }
1783
1784
2/2
✓ Branch 0 taken 5081 times.
✓ Branch 1 taken 15871 times.
20952 if(!seekhero)
1785 {
1786
4/5
✓ Branch 0 taken 3297 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3079 times.
✓ Branch 3 taken 5287 times.
✓ Branch 4 taken 4208 times.
15871 switch(dir)
1787 {
1788 case down:
1789 3079 fire_angle=PI*(int64_t(zc_oldrand()%20)+10)/40;
1790 3079 wx=x;
1791 3079 wy=y+8;
1792 3079 break;
1793
1794 case -1:
1795 case up:
1796 3297 fire_angle=PI*(int64_t(zc_oldrand()%20)+50)/40;
1797 3297 wx=x;
1798 3297 wy=y-8;
1799 3297 break;
1800
1801 case left:
1802 5287 fire_angle=PI*(int64_t(zc_oldrand()%20)+30)/40;
1803 5287 wx=x-8;
1804 5287 wy=y;
1805 5287 break;
1806
1807 case right:
1808 4208 fire_angle=PI*(int64_t(zc_oldrand()%20)+70)/40;
1809 4208 wx=x+8;
1810 4208 wy=y;
1811 4208 break;
1812 }
1813
1814
3/4
✓ Branch 0 taken 136 times.
✓ Branch 1 taken 15735 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 136 times.
15871 if(wpn==ewFlame || wpn==ewFlame2)
1815 {
1816
2/4
✓ Branch 0 taken 15735 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15735 times.
15735 if(fire_angle==-PI || fire_angle==PI) wdir=left;
1817
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle==-PI/2) wdir=up;
1818
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle==PI/2) wdir=down;
1819
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle==0) wdir=right;
1820
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle<-PI/2) wdir=l_up;
1821
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle<0) wdir=r_up;
1822
2/2
✓ Branch 0 taken 1498 times.
✓ Branch 1 taken 14237 times.
15735 else if(fire_angle<(PI/2)) wdir=r_down;
1823
2/2
✓ Branch 0 taken 10121 times.
✓ Branch 1 taken 4116 times.
14237 else if(fire_angle<PI) wdir=l_down;
1824 15735 }
1825 15871 }
1826 else
1827 {
1828 5081 wx = x;
1829 5081 wy = y;
1830 }
1831
1832
2/2
✓ Branch 0 taken 5081 times.
✓ Branch 1 taken 15871 times.
20952 addEwpn(wx+xoff,wy+yoff,z,wpn,2,wdp,seekhero ? 0xFF : wdir, getUID(), 0, fakez);
1833 20952 sfx(wpnsfx(wpn),pan(int32_t(x)));
1834
1835 20952 int32_t i=Ewpns.Count()-1;
1836 20952 weapon *ew = (weapon*)(Ewpns.spr(i));
1837 20952 ew->moveflags &= ~move_can_pitfall; //No falling in pits
1838
1839
4/4
✓ Branch 0 taken 15871 times.
✓ Branch 1 taken 5081 times.
✓ Branch 2 taken 7914 times.
✓ Branch 3 taken 7957 times.
20952 if(!seekhero && (zc_oldrand()&4))
1840 {
1841 7957 ew->angular=true;
1842 7957 ew->angle=fire_angle;
1843 7957 }
1844
1845
4/4
✓ Branch 0 taken 20676 times.
✓ Branch 1 taken 276 times.
✓ Branch 2 taken 317 times.
✓ Branch 3 taken 20359 times.
20952 if(wpn==ewFlame && wpnsbuf[ewFLAME].frames>1)
1846 {
1847 20359 ew->aframe=zc_oldrand()%wpnsbuf[ewFLAME].frames;
1848
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20359 times.
20359 if ( ew->do_animation ) ew->tile+=ew->aframe;
1849 20359 }
1850
1851
2/2
✓ Branch 0 taken 20952 times.
✓ Branch 1 taken 766199 times.
787151 for(int32_t j=Ewpns.Count()-1; j>0; j--)
1852 {
1853 766199 Ewpns.swap(j,j-1);
1854 766199 }
1855 20952 }
1856
1857 44653 void enemy::FireWeapon()
1858 {
1859 /*
1860 * Type:
1861 * 0x01: Boss fireball
1862 * 0x02: Seeks Hero
1863 * 0x04: Fast projectile
1864 * 0x00-0x30: If 0x02, slants toward (type>>3)-1
1865 */
1866
1867
2/2
✓ Branch 0 taken 44522 times.
✓ Branch 1 taken 131 times.
44653 if (wpn < 1) return;
1868
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 44522 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
44522 if(wpn<wEnemyWeapons && dmisc1!=9 && dmisc1!=10 && (wpn < wScript1 && wpn > wScript10) ) // Summoning doesn't require weapons
1869 return;
1870
1871
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 44522 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
44522 if(wpn==ewFireTrail && dmisc1>=e1t3SHOTS && dmisc1<=e1t8SHOTS)
1872 dmisc1 = e1tEACHTILE;
1873
1874 44522 int32_t xoff = 0;
1875 44522 int32_t yoff = 0;
1876
1/2
✓ Branch 0 taken 44522 times.
✗ Branch 1 not taken.
44522 if (SIZEflags & OVERRIDE_HIT_WIDTH)
1877 {
1878 xoff += hxofs;
1879 if (weapoverrideFLAGS & OVERRIDE_HIT_WIDTH)
1880 xoff += (hit_width / 2) - (weap_tilew * 8);
1881 else
1882 xoff += (hit_width / 2) - 8;
1883 }
1884
1/2
✓ Branch 0 taken 44522 times.
✗ Branch 1 not taken.
44522 if (SIZEflags & OVERRIDE_HIT_HEIGHT)
1885 {
1886 yoff += hyofs;
1887 if (weapoverrideFLAGS & OVERRIDE_HIT_HEIGHT)
1888 yoff += (hit_height / 2) - (weap_tileh * 8);
1889 else
1890 yoff += (hit_height / 2) - 8;
1891 }
1892
1893 // TODO(crash): check that .add succeeds.
1894
1895
5/8
✓ Branch 0 taken 646 times.
✓ Branch 1 taken 41523 times.
✓ Branch 2 taken 1839 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 416 times.
✓ Branch 5 taken 98 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
44522 switch(dmisc1)
1896 {
1897 case e1t5SHOTS: //BS-Aquamentus
1898 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^left)+5)<<3),wdp,dir,-1, getUID(),false));
1899 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1900 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^right)+5)<<3),wdp,dir,-1, getUID(),false));
1901 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1902
1903 [[fallthrough]];
1904 case e1t3SHOTSFAST:
1905 case e1t3SHOTS: //Aquamentus
1906
7/14
✓ Branch 0 taken 646 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 646 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 646 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 646 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 646 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 646 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 646 times.
✗ Branch 13 not taken.
646 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^left)+1)<<3)+(dmisc1==e1t3SHOTSFAST ? 4:0),wdp,dir,-1, getUID(),false));
1907 646 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1908
7/14
✓ Branch 0 taken 646 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 646 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 646 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 646 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 646 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 646 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 646 times.
✗ Branch 13 not taken.
646 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^right)+1)<<3)+(dmisc1==e1t3SHOTSFAST ? 4:0),wdp,dir,-1, getUID(),false));
1909 646 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1910
1911 [[fallthrough]];
1912 default:
1913
12/20
✓ Branch 0 taken 42169 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 42169 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 42169 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 42169 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 42169 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 5 times.
✓ Branch 11 taken 42164 times.
✓ Branch 12 taken 42169 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 18238 times.
✓ Branch 15 taken 23931 times.
✓ Branch 16 taken 42169 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 42169 times.
✗ Branch 19 not taken.
42169 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(dmisc1==e1t3SHOTSFAST || dmisc1==e1tFAST ? 4:0),wdp,wpn==ewFireball2 || wpn==ewFireball ? 0:dir,-1, getUID(),false));
1914 42169 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1915 42169 sfx(wpnsfx(wpn),pan(int32_t(x)));
1916 42169 break;
1917
1918 case e1tSLANT:
1919 {
1920 416 int32_t slant = 0;
1921
1922
10/10
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 304 times.
✓ Branch 2 taken 200 times.
✓ Branch 3 taken 216 times.
✓ Branch 4 taken 47 times.
✓ Branch 5 taken 161 times.
✓ Branch 6 taken 61 times.
✓ Branch 7 taken 316 times.
✓ Branch 8 taken 138 times.
✓ Branch 9 taken 178 times.
416 if(((Hero.x-x) < -8 && dir==up) || ((Hero.x-x) > 8 && dir==down) || ((Hero.y-y) < -8 && dir==left) || ((Hero.y-y) > 8 && dir==right))
1923 246 slant = left;
1924
10/10
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 68 times.
✓ Branch 3 taken 108 times.
✓ Branch 4 taken 37 times.
✓ Branch 5 taken 33 times.
✓ Branch 6 taken 55 times.
✓ Branch 7 taken 86 times.
✓ Branch 8 taken 25 times.
✓ Branch 9 taken 61 times.
178 else if(((Hero.x-x) > 8 && dir==up) || ((Hero.x-x) < -8 && dir==down) || ((Hero.y-y) > 8 && dir==left) || ((Hero.y-y) < -8 && dir==right))
1925 117 slant = right;
1926
1927
9/18
✓ Branch 0 taken 330 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 330 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 330 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 330 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 330 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 330 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 330 times.
✓ Branch 14 taken 330 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 330 times.
✗ Branch 17 not taken.
330 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^slant)+1)<<3),wdp,wpn==ewFireball2 || wpn==ewFireball ? 0:dir,-1, getUID(),false));
1928 330 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1929 330 sfx(wpnsfx(wpn),pan(int32_t(x)));
1930 330 break;
1931 }
1932
1933 case e1t8SHOTS: //Fire Wizzrobe
1934
7/14
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 98 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 98 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 98 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 98 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 98 times.
✗ Branch 13 not taken.
98 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,l_up,-1, getUID(),false));
1935 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1936 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1937
7/14
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 98 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 98 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 98 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 98 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 98 times.
✗ Branch 13 not taken.
98 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,l_down,-1, getUID(),false));
1938 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1939 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1940
7/14
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 98 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 98 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 98 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 98 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 98 times.
✗ Branch 13 not taken.
98 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,r_up,-1, getUID(),false));
1941 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1942 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1943
7/14
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 98 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 98 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 98 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 98 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 98 times.
✗ Branch 13 not taken.
98 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,r_down,-1, getUID(),false));
1944 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1945 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1946
1947 [[fallthrough]];
1948 case e1t4SHOTS: //Stalfos 3
1949
7/14
✓ Branch 0 taken 1937 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1937 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1937 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1937 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1937 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1937 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1937 times.
✗ Branch 13 not taken.
1937 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,up,-1, getUID(),false));
1950 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1951 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1952
7/14
✓ Branch 0 taken 1937 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1937 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1937 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1937 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1937 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1937 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1937 times.
✗ Branch 13 not taken.
1937 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,down,-1, getUID(),false));
1953 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1954 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1955
7/14
✓ Branch 0 taken 1937 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1937 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1937 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1937 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1937 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1937 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1937 times.
✗ Branch 13 not taken.
1937 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,left,-1, getUID(),false));
1956 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1957 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1958
7/14
✓ Branch 0 taken 1937 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1937 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1937 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1937 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1937 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1937 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1937 times.
✗ Branch 13 not taken.
1937 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,right,-1, getUID(),false));
1959 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1960 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1961 1937 sfx(wpnsfx(wpn),pan(int32_t(x)));
1962 1937 break;
1963
1964 case e1tSUMMON: // Bat Wizzrobe
1965 {
1966 if(dmisc4==0) break; // Summon 0
1967
1968 int32_t bc=0;
1969
1970 for(int32_t gc=0; gc<guys.Count(); gc++)
1971 {
1972 if((((enemy*)guys.spr(gc))->id) == dmisc3)
1973 {
1974 ++bc;
1975 }
1976 }
1977
1978 if(bc<=40) // Not too many enemies
1979 {
1980 int32_t kids = guys.Count();
1981 int32_t bats=(zc_oldrand()%zc_max(1,dmisc4))+1;
1982
1983 for(int32_t i=0; i<bats; i++)
1984 {
1985 if(addchild(x,y,dmisc3,-10, this->script_UID))
1986 {
1987 ((enemy*)guys.spr(kids+i))->count_enemy = false;
1988
1989 }
1990 }
1991
1992 sfx(firesfx, pan(int32_t(x)));
1993 }
1994
1995 break;
1996 }
1997
1998 case e1tSUMMONLAYER: // Summoner
1999 {
2000 if(count_layer_enemies()==0)
2001 {
2002 break;
2003 }
2004
2005 int32_t kids = guys.Count();
2006
2007 if(kids<40)
2008 {
2009 int32_t newguys=(zc_oldrand()%3)+1;
2010 bool summoned=false;
2011
2012 for(int32_t i=0; i<newguys; i++)
2013 {
2014 int32_t id2=vbound(random_layer_enemy(),eSTART,eMAXGUYS-1);
2015 int32_t x2=0;
2016 int32_t y2=0;
2017
2018 for(int32_t k=0; k<20; ++k)
2019 {
2020 x2=16*((zc_oldrand()%12)+2);
2021 y2=16*((zc_oldrand()%7)+2);
2022
2023 if((!m_walkflag(x2,y2,0,dir))&&((abs(x2-Hero.getX())>=32)||(abs(y2-Hero.getY())>=32)))
2024 {
2025 if(addchild(x2,y2,get_qr(qr_ENEMIESZAXIS) ? 64 : 0,id2,-10, this->script_UID))
2026 {
2027 ((enemy*)guys.spr(kids+i))->count_enemy = false;
2028 if (get_qr(qr_ENEMIESZAXIS) && (((enemy*)guys.spr(kids+i))->moveflags & move_use_fake_z))
2029 {
2030 ((enemy*)guys.spr(kids+i))->fakez = 64;
2031 ((enemy*)guys.spr(kids+i))->z = 0;
2032 }
2033 }
2034
2035 summoned=true;
2036 break;
2037 }
2038 }
2039 }
2040
2041 if(summoned)
2042 {
2043 sfx(firesfx, pan(int32_t(x)));
2044 }
2045 }
2046
2047 break;
2048 }
2049 }
2050 44567 }
2051
2052
2053 // Hit the shield(s)?
2054 // Apparently, this function is only used for hookshots...
2055 2767 bool enemy::hitshield(int32_t wpnx, int32_t wpny, int32_t xdir)
2056 {
2057
6/6
✓ Branch 0 taken 976 times.
✓ Branch 1 taken 1791 times.
✓ Branch 2 taken 975 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 141 times.
✓ Branch 5 taken 834 times.
2767 if(!(family==eeWALK || family==eeFIRE || family==eeOTHER))
2058 834 return false;
2059
2060 1933 bool ret = false;
2061
2062 // TODO: There must be some bitwise operations that can simplify this...
2063
9/12
✓ Branch 0 taken 1207 times.
✓ Branch 1 taken 726 times.
✓ Branch 2 taken 43 times.
✓ Branch 3 taken 683 times.
✓ Branch 4 taken 27 times.
✓ Branch 5 taken 16 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 699 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 699 times.
✓ Branch 10 taken 699 times.
✗ Branch 11 not taken.
1933 if(wpny > y) ret = ((flags&guy_shield_front && xdir==down) || (flags&guy_shield_back && xdir==up) || (flags&guy_shield_left && xdir==left) || (flags&guy_shield_right && xdir==right));
2064
9/12
✓ Branch 0 taken 383 times.
✓ Branch 1 taken 824 times.
✓ Branch 2 taken 46 times.
✓ Branch 3 taken 778 times.
✓ Branch 4 taken 33 times.
✓ Branch 5 taken 13 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 811 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 811 times.
✓ Branch 10 taken 811 times.
✗ Branch 11 not taken.
1207 else if(wpny < y) ret = ((flags&guy_shield_front && xdir==up) || (flags&guy_shield_back && xdir==down) || (flags&guy_shield_left && xdir==right) || (flags&guy_shield_right && xdir==left));
2065
2066
11/14
✓ Branch 0 taken 1065 times.
✓ Branch 1 taken 868 times.
✓ Branch 2 taken 19 times.
✓ Branch 3 taken 849 times.
✓ Branch 4 taken 24 times.
✓ Branch 5 taken 825 times.
✓ Branch 6 taken 9 times.
✓ Branch 7 taken 15 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 840 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 840 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 840 times.
1933 if(wpnx < x) ret = ret || ((flags&guy_shield_front && xdir==left) || (flags&guy_shield_back && xdir==right) || (flags&guy_shield_left && xdir==down) || (flags&guy_shield_right && xdir==up));
2067
11/14
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 876 times.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 863 times.
✓ Branch 4 taken 36 times.
✓ Branch 5 taken 827 times.
✓ Branch 6 taken 19 times.
✓ Branch 7 taken 17 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 844 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 844 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 844 times.
1065 else if(wpnx > x) ret = ret || ((flags&guy_shield_front && xdir==right) || (flags&guy_shield_back && xdir==left) || (flags&guy_shield_left && xdir==up) || (flags&guy_shield_right && xdir==down));
2068
2069 1933 return ret;
2070 2767 }
2071
2072
2073 //! Weapon Editor for 2.6
2074 //To hell with this. I'm writing new functions to resolve weapon type and defence. -Z
2075
2076
2077 //converts a wqeapon ID to its defence index.
2078 126874 int32_t weaponToDefence(int32_t wid)
2079 {
2080
23/47
✗ Branch 0 not taken.
✓ Branch 1 taken 64432 times.
✓ Branch 2 taken 9432 times.
✓ Branch 3 taken 25029 times.
✓ Branch 4 taken 4207 times.
✓ Branch 5 taken 37 times.
✓ Branch 6 taken 48 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3146 times.
✓ Branch 9 taken 9836 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 269 times.
✓ Branch 13 taken 1217 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 512 times.
✓ Branch 17 taken 1459 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 2036 times.
✓ Branch 20 taken 2767 times.
✓ Branch 21 taken 610 times.
✗ Branch 22 not taken.
✓ Branch 23 taken 240 times.
✓ Branch 24 taken 469 times.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✓ Branch 28 taken 19 times.
✗ Branch 29 not taken.
✓ Branch 30 taken 26 times.
✗ Branch 31 not taken.
✓ Branch 32 taken 12 times.
✓ Branch 33 taken 77 times.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✓ Branch 39 taken 993 times.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
✓ Branch 42 taken 1 times.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
✗ Branch 45 not taken.
✗ Branch 46 not taken.
126874 switch(wid)
2081 {
2082 case wNone: return -1;
2083 64432 case wSword: return edefSWORD;
2084 9432 case wBeam: return edefBEAM;
2085 25029 case wBrang: return edefBRANG;
2086 4207 case wBomb: return edefBOMB;
2087 37 case wSBomb: return edefSBOMB;
2088 48 case wLitBomb: return edefBOMB;
2089 case wLitSBomb: return edefSBOMB;
2090 3146 case wArrow: return edefARROW;
2091 9836 case wFire: return edefFIRE;
2092 case wWhistle:
2093 {
2094 return edefWhistle;
2095 }
2096 case wBait: return edefBAIT;
2097 269 case wWand: return edefWAND;
2098 1217 case wMagic: return edefMAGIC;
2099 case wCatching: return -1;
2100 case wWind: return edefWIND;
2101 512 case wRefMagic: return edefREFMAGIC;
2102 1459 case wRefFireball: return edefREFBALL;
2103 case wRefRock: return edefREFROCK;
2104 2036 case wHammer: return edefHAMMER;
2105 2767 case wHookshot: return edefHOOKSHOT;
2106 610 case wHSHandle: return edefHOOKSHOT;
2107 case wHSChain: return edefHOOKSHOT;
2108 240 case wSSparkle: return edefSPARKLE;
2109 469 case wFSparkle: return edefSPARKLE;
2110 case wSmack: return -1; // is this the candle object?
2111 case wPhantom: return -1; //engine created visual effects.
2112 case wCByrna: return edefBYRNA;
2113 19 case wRefBeam: return edefREFBEAM;
2114 case wStomp: return edefSTOMP;
2115 26 case wScript1: return edefSCRIPT01;
2116 case wScript2: return edefSCRIPT02;
2117 12 case wScript3: return edefSCRIPT03;
2118 77 case wScript4: return edefSCRIPT04;
2119 case wScript5: return edefSCRIPT05;
2120 case wScript6: return edefSCRIPT06;
2121 case wScript7: return edefSCRIPT07;
2122 case wScript8: return edefSCRIPT08;
2123 case wScript9: return edefSCRIPT09;
2124 993 case wScript10: return edefSCRIPT10;
2125 case wIce: return edefICE;
2126 case wSound: return edefSONIC;
2127 1 case wThrown: return edefTHROWN;
2128 case wRefArrow: return edefREFARROW;
2129 case wRefFire: return edefREFFIRE;
2130 case wRefFire2: return edefREFFIRE2;
2131 //case wPot: return edefPOT;
2132 // case wLitZap: return edefELECTRIC;
2133 // case wZ3Sword: return edefZ3SWORD;
2134 // case wLASWord: return edefLASWORD;
2135 // case wSpinAttk: return edefSPINATTK;
2136 // case wShield: return edefSHIELD;
2137 // case wTrowel: return edefTROWEL;
2138
2139 default: return -1;
2140 }
2141 126874 }
2142
2143 126874 int32_t getDefType(weapon *w)
2144 {
2145 126874 int32_t id = getWeaponID(w);
2146 126874 int32_t edef = weaponToDefence(id);
2147
2/2
✓ Branch 0 taken 123497 times.
✓ Branch 1 taken 3377 times.
126874 if(edef == edefHOOKSHOT)
2148 {
2149
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3377 times.
3377 if(w->family_class == itype_switchhook)
2150 return edefSwitchHook;
2151 3377 }
2152 126874 return edef;
2153 126874 }
2154
2155 225952 int32_t getWeaponID(weapon *w)
2156 {
2157 225952 int32_t usewpn = w->useweapon;
2158
2/2
✓ Branch 0 taken 230 times.
✓ Branch 1 taken 225722 times.
225952 return (usewpn > 0) ? usewpn : w->id;
2159 }
2160
2161 126874 int32_t enemy::resolveEnemyDefence(weapon *w)
2162 {
2163 //sword edef is 9, but we're reading it at 0
2164 //,
2165 126874 int32_t weapondef = 0;
2166 126874 int32_t wdeftype = getDefType(w);
2167 126874 int32_t usedef = w->usedefence;
2168
2169
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 126874 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
126874 if ( usedef > 0 && (wdeftype < 0 || wdeftype >= edefLAST255 || defense[wdeftype] == 0))
2170 {
2171 weapondef = usedef*-1;
2172 }
2173
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126874 times.
126874 else if(unsigned(wdeftype) < edefLAST255)
2174 {
2175 126874 weapondef = wdeftype;
2176 126874 }
2177 126874 return weapondef;
2178 }
2179
2180 137424 byte get_def_ignrflag(int32_t edef)
2181 {
2182
3/3
✓ Branch 0 taken 114479 times.
✓ Branch 1 taken 3683 times.
✓ Branch 2 taken 19262 times.
137424 switch(edef)
2183 {
2184 case edIGNORE:
2185 case edIGNOREL1:
2186 case edSTUNORIGNORE:
2187 19262 return WPNUNB_IGNR;
2188 case edSTUNORCHINK:
2189 case edCHINK:
2190 case edCHINKL1:
2191 case edCHINKL2:
2192 case edCHINKL4:
2193 case edCHINKL6:
2194 case edCHINKL8:
2195 case edCHINKL10:
2196 case edLEVELCHINK2:
2197 case edLEVELCHINK3:
2198 case edLEVELCHINK4:
2199 case edLEVELCHINK5:
2200 3683 return WPNUNB_BLOCK;
2201 }
2202 114479 return 0;
2203 137424 }
2204
2205 137424 int32_t conv_edef_unblockable(int32_t edef, byte unblockable)
2206 {
2207
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137424 times.
137424 if(!(unblockable&get_def_ignrflag(edef))) return edef;
2208 switch(edef)
2209 {
2210 case edIGNORE:
2211 case edIGNOREL1:
2212 case edCHINK:
2213 case edCHINKL1:
2214 case edCHINKL2:
2215 case edCHINKL4:
2216 case edCHINKL6:
2217 case edCHINKL8:
2218 case edCHINKL10:
2219 case edLEVELCHINK2:
2220 case edLEVELCHINK3:
2221 case edLEVELCHINK4:
2222 case edLEVELCHINK5:
2223 return edNORMAL;
2224 case edSTUNORIGNORE:
2225 case edSTUNORCHINK:
2226 return edSTUNONLY;
2227 }
2228 return edef;
2229 137424 }
2230
2231 // Do we do damage?
2232 // 0: takehit returns 0
2233 // 1: takehit returns 1
2234 // -1: do damage
2235 //The input from resolveEnemyDefence() for the param 'edef' is negative if a specific defence RESULT is being used.
2236 125881 int32_t enemy::defendNew(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable) //May need *wpn to set return on brangs and hookshots
2237 {
2238
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125881 times.
125881 if(switch_hooked) return 0;
2239 125881 int32_t tempx = x;
2240 125881 int32_t tempy = y;
2241 125881 int32_t the_defence = 0;
2242
1/2
✓ Branch 0 taken 125881 times.
✗ Branch 1 not taken.
125881 if ( edef < 0 ) //we are using a specific base default defence for a weapon
2243 {
2244 the_defence = edef*-1; //A specific defence type.
2245 }
2246 125881 else the_defence = defense[edef];
2247
2248 125881 the_defence = conv_edef_unblockable(the_defence, unblockable);
2249
2250
3/4
✓ Branch 0 taken 6573 times.
✓ Branch 1 taken 119308 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6573 times.
125881 if(shieldCanBlock && !(unblockable&WPNUNB_SHLD))
2251 {
2252
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 6566 times.
✓ Branch 2 taken 7 times.
6573 switch(the_defence)
2253 {
2254 case edIGNORE:
2255 7 return 0;
2256 case edIGNOREL1:
2257 case edSTUNORIGNORE:
2258 if(*power <= 0)
2259 return 0;
2260 }
2261 6566 sfx(WAV_CHINK,pan(int32_t(x)));
2262 6566 return 1;
2263 }
2264
2265 119308 int32_t new_id = id;
2266 119308 int32_t effect_type = dmisc15;
2267 119308 int32_t delay_timer = 90;
2268 119308 enemy *gleeok = NULL;
2269 119308 enemy *ptra = NULL;
2270 119308 int32_t c = 0;
2271
2272
16/29
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 492 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1931 times.
✓ Branch 6 taken 1862 times.
✓ Branch 7 taken 113 times.
✓ Branch 8 taken 129 times.
✓ Branch 9 taken 1 times.
✓ Branch 10 taken 43 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 945 times.
✓ Branch 13 taken 17324 times.
✓ Branch 14 taken 883 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 2175 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✓ Branch 22 taken 71 times.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✓ Branch 25 taken 158 times.
✓ Branch 26 taken 105 times.
✓ Branch 27 taken 4 times.
✓ Branch 28 taken 93072 times.
119308 switch(the_defence)
2273 {
2274 case edREPLACE:
2275 {
2276 sclk = 0;
2277 if ( dmisc16 > 0 ) new_id = dmisc16;
2278 else new_id = id+1;
2279 if ( new_id > 511 ) new_id = id; //Sanity bound to legal enemy IDs.
2280 if ( dmisc17 > 0 ) delay_timer = dmisc17;
2281 //if ( dmisc18 > 0 ) dummy_wpn_id = dmisc18;
2282
2283 //Z_scripterrlog("new id is %d\n", new_id);
2284 switch(guysbuf[new_id&0xFFF].family)
2285 {
2286 //Fixme: possible enemy memory leak. (minor)
2287 case eeWALK:
2288 {
2289 enemy *e = new eStalfos(x,y,new_id,clk);
2290 guys.add(e);
2291 }
2292 break;
2293
2294 case eeLEV:
2295 {
2296 enemy *e = new eLeever(x,y,new_id,clk);
2297 guys.add(e);
2298 }
2299 break;
2300
2301 case eeTEK:
2302 {
2303 enemy *e = new eTektite(x,y,new_id,clk);
2304 guys.add(e);
2305 }
2306 break;
2307
2308 case eePEAHAT:
2309 {
2310 enemy *e = new ePeahat(x,y,new_id,clk);
2311 guys.add(e);
2312 }
2313 break;
2314
2315 case eeZORA:
2316 {
2317 enemy *e = new eZora(x,y,new_id,clk);
2318 guys.add(e);
2319 }
2320 break;
2321
2322 case eeGHINI:
2323 {
2324 enemy *e = new eGhini(x,y,new_id,clk);
2325 guys.add(e);
2326 }
2327 break;
2328
2329 case eeKEESE:
2330 {
2331 enemy *e = new eKeese(x,y,new_id,clk);
2332 guys.add(e);
2333 }
2334 break;
2335
2336 case eeWIZZ:
2337 {
2338 enemy *e = new eWizzrobe(x,y,new_id,clk);
2339 guys.add(e);
2340 }
2341 break;
2342
2343 case eePROJECTILE:
2344 {
2345 enemy *e = new eProjectile(x,y,new_id,clk);
2346 guys.add(e);
2347 }
2348 break;
2349
2350 case eeWALLM:
2351 {
2352 enemy *e = new eWallM(x,y,new_id,clk);
2353 guys.add(e);
2354 }
2355 break;
2356
2357 case eeAQUA:
2358 {
2359 enemy *e = new eAquamentus(x,y,new_id,clk);
2360 guys.add(e);
2361 e->x = x;
2362 e->y = y;
2363 }
2364 break;
2365
2366 case eeMOLD:
2367 {
2368 enemy *e = new eMoldorm(x,y,new_id,zc_max(1,zc_min(254,guysbuf[new_id&0xFFF].attributes[0])));
2369 guys.add(e);
2370 e->x = x;
2371 e->y = y;
2372 }
2373 break;
2374
2375 case eeMANHAN:
2376 {
2377 enemy *e = new eManhandla(x,y,new_id,clk);
2378 guys.add(e);
2379 e->x = x;
2380 e->y = y;
2381 }
2382 break;
2383
2384 case eeGLEEOK:
2385 {
2386 *power = 0;
2387 gleeok = new eGleeok(x,y,new_id,guysbuf[new_id&0xFFF].attributes[0]);
2388 guys.add(gleeok);
2389 // TODO(crash): check that .add succeeds.
2390 ((enemy*)guys.spr(guys.Count()-1))->hclk = delay_timer;
2391 new_id &= 0xFFF;
2392 int32_t head_cnt = zc_max(1,zc_min(254,guysbuf[new_id&0xFFF].attributes[0]));
2393 Z_scripterrlog("Gleeok head count is %d\n",head_cnt);
2394 for(int32_t i=0; i<head_cnt; i++)
2395 {
2396 //enemy *e = new esGleeok(x,y,new_id+0x1000,clk,gleeok);
2397 if(!guys.add(new esGleeok((zfix)x,(zfix)y,new_id+0x1000,c, gleeok)))
2398 {
2399 al_trace("Gleeok head %d could not be created!\n",i+1);
2400
2401 for(int32_t j=0; j<i+1; j++)
2402 {
2403 guys.del(guys.Count()-1);
2404 }
2405
2406 break;
2407 }
2408 else
2409 {
2410 ((enemy*)guys.spr(guys.Count()-1))->hclk = delay_timer;
2411 }
2412
2413 c-=guysbuf[new_id].attributes[3];
2414 }
2415 return 1;
2416 }
2417
2418 case eeGHOMA:
2419 {
2420 enemy *e = new eGohma(x,y,new_id,clk);
2421 guys.add(e);
2422 e->x = x;
2423 e->y = y;
2424 }
2425 break;
2426
2427 case eeLANM:
2428 {
2429 enemy *e = new eLanmola(x,y,new_id,zc_max(1,zc_min(253,guysbuf[new_id&0xFFF].attributes[0])));
2430 guys.add(e);
2431 e->x = x;
2432 e->y = y;
2433 }
2434 break;
2435
2436 case eeGANON:
2437 {
2438 enemy *e = new eGanon(x,y,new_id,clk);
2439 guys.add(e);
2440 e->x = x;
2441 e->y = y;
2442 }
2443 break;
2444
2445 case eeFAIRY:
2446 {
2447 enemy *e = new eItemFairy(x,y,new_id+0x1000*clk,clk);
2448 guys.add(e);
2449 e->x = x;
2450 e->y = y;
2451 }
2452 break;
2453
2454 case eeFIRE:
2455 {
2456 enemy *e = new eFire(x,y,new_id,clk);
2457 guys.add(e);
2458 e->x = x;
2459 e->y = y;
2460 }
2461 break;
2462
2463 case eeOTHER:
2464 {
2465 enemy *e = new eOther(x,y,new_id,clk);
2466 guys.add(e);
2467 e->x = x;
2468 e->y = y;
2469 }
2470 break;
2471
2472 case eeSPINTILE:
2473 {
2474 enemy *e = new eSpinTile(x,y,new_id,clk);
2475 guys.add(e);
2476 e->x = x;
2477 e->y = y;
2478 }
2479 break;
2480
2481 // and these enemies use the misc10/misc2 value
2482 case eeROCK:
2483 {
2484 switch(guysbuf[new_id&0xFFF].attributes[9])
2485 {
2486 case 1:
2487 {
2488 enemy *e = new eBoulder(x,y,new_id,clk);
2489 guys.add(e);
2490 e->x = x;
2491 e->y = y;
2492 }
2493 break;
2494
2495 case 0:
2496 default:
2497 {
2498 enemy *e = new eRock(x,y,new_id,clk);
2499 guys.add(e);
2500 e->x = x;
2501 e->y = y;
2502 }
2503 break;
2504 }
2505
2506 break;
2507 }
2508
2509 case eeTRAP:
2510 {
2511 switch(guysbuf[new_id&0xFFF].attributes[1])
2512 {
2513 case 1:
2514 {
2515 enemy *e = new eTrap2(x,y,new_id,clk);
2516 guys.add(e);
2517 e->x = x;
2518 e->y = y;
2519 }
2520 break;
2521
2522 case 0:
2523 default:
2524 {
2525 enemy *e = new eTrap(x,y,new_id,clk);
2526 guys.add(e);
2527 e->x = x;
2528 e->y = y;
2529 }
2530 break;
2531 }
2532
2533 break;
2534 }
2535
2536 case eeDONGO:
2537 {
2538 switch(guysbuf[new_id&0xFFF].attributes[9])
2539 {
2540 case 1:
2541 {
2542 enemy *e = new eDodongo2(x,y,new_id,clk);
2543 guys.add(e);
2544 e->x = x;
2545 e->y = y;
2546 }
2547 break;
2548
2549 case 0:
2550 default:
2551 {
2552 enemy *e = new eDodongo(x,y,new_id,clk);
2553 guys.add(e);
2554 e->x = x;
2555 e->y = y;
2556 }
2557 break;
2558 }
2559
2560 break;
2561 }
2562
2563 case eeDIG:
2564 {
2565 switch(guysbuf[new_id&0xFFF].attributes[9])
2566 {
2567 case 1:
2568 {
2569 enemy *e = new eLilDig(x,y,new_id,clk);
2570 guys.add(e);
2571 e->x = x;
2572 e->y = y;
2573 }
2574 break;
2575
2576 case 0:
2577 default:
2578 {
2579 enemy *e = new eBigDig(x,y,new_id,clk);
2580 guys.add(e);
2581 e->x = x;
2582 e->y = y;
2583 }
2584 break;
2585 }
2586
2587 break;
2588 }
2589
2590 case eePATRA:
2591 {
2592 switch(guysbuf[new_id&0xFFF].attributes[9])
2593 {
2594 case 1:
2595 {
2596 if (get_qr(qr_HARDCODED_BS_PATRA))
2597 {
2598 enemy *e = new ePatraBS(x,y,new_id,clk);
2599 guys.add(e);
2600 e->x = x;
2601 e->y = y;
2602 break;
2603 }
2604 }
2605 [[fallthrough]];
2606 case 0:
2607 default:
2608 {
2609 enemy *e = new ePatra(x,y,new_id,clk);
2610 guys.add(e);
2611 e->x = x;
2612 e->y = y;
2613 }
2614 break;
2615 }
2616
2617 break;
2618 }
2619
2620 case eeGUY:
2621 {
2622 switch(guysbuf[new_id&0xFFF].attributes[9])
2623 {
2624 case 1:
2625 {
2626 enemy *e = new eTrigger(x,y,new_id,clk);
2627 guys.add(e);
2628 }
2629 break;
2630
2631 case 0:
2632 default:
2633 {
2634 enemy *e = new eNPC(x,y,new_id,clk);
2635 guys.add(e);
2636 }
2637 break;
2638 }
2639
2640 break;
2641 }
2642
2643 case eeSCRIPT01:
2644 case eeSCRIPT02:
2645 case eeSCRIPT03:
2646 case eeSCRIPT04:
2647 case eeSCRIPT05:
2648 case eeSCRIPT06:
2649 case eeSCRIPT07:
2650 case eeSCRIPT08:
2651 case eeSCRIPT09:
2652 case eeSCRIPT10:
2653 case eeSCRIPT11:
2654 case eeSCRIPT12:
2655 case eeSCRIPT13:
2656 case eeSCRIPT14:
2657 case eeSCRIPT15:
2658 case eeSCRIPT16:
2659 case eeSCRIPT17:
2660 case eeSCRIPT18:
2661 case eeSCRIPT19:
2662 case eeSCRIPT20:
2663 {
2664 enemy *e = new eScript(x,y,new_id,clk);
2665 guys.add(e);
2666 e->x = x;
2667 e->y = y;
2668 break;
2669 }
2670
2671
2672 case eeFFRIENDLY01:
2673 case eeFFRIENDLY02:
2674 case eeFFRIENDLY03:
2675 case eeFFRIENDLY04:
2676 case eeFFRIENDLY05:
2677 case eeFFRIENDLY06:
2678 case eeFFRIENDLY07:
2679 case eeFFRIENDLY08:
2680 case eeFFRIENDLY09:
2681 case eeFFRIENDLY10:
2682 {
2683 enemy *e = new eFriendly(x,y,new_id,clk);
2684 guys.add(e);
2685 e->x = x;
2686 e->y = y;
2687 break;
2688 }
2689
2690
2691 default: break;
2692 }
2693
2694 // add segments of segmented enemies
2695 int32_t c=0;
2696
2697 switch(guysbuf[new_id&0xFFF].family)
2698 {
2699 case eeMOLD:
2700 {
2701 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
2702 new_id &= 0xFFF;
2703
2704 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[new_id].attributes[0])); i++)
2705 {
2706 //christ this is messy -DD
2707 int32_t segclk = -i*((int32_t)(8.0/(zslongToFix(guysbuf[new_id&0xFFF].step*100))));
2708
2709 if(!guys.add(new esMoldorm((zfix)x,(zfix)y,new_id+0x1000,segclk)))
2710 {
2711 al_trace("Moldorm segment %d could not be created!\n",i+1);
2712
2713 for(int32_t j=0; j<i+1; j++)
2714 guys.del(guys.Count()-1);
2715
2716 return 0;
2717 }
2718
2719 if(i>0)
2720 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
2721
2722
2723 }
2724
2725 break;
2726 }
2727
2728 case eeLANM:
2729 {
2730 new_id &= 0xFFF;
2731 int32_t shft = guysbuf[new_id].attributes[1];
2732 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
2733 enemy *e = new esLanmola((zfix)x,(zfix)y,new_id+0x1000,0);
2734
2735 if(!guys.add(e))
2736 {
2737 al_trace("Lanmola segment 1 could not be created!\n");
2738 guys.del(guys.Count()-1);
2739 return 0;
2740 }
2741 e->x = x;
2742 e->y = y;
2743
2744
2745
2746 for(int32_t i=1; i<zc_max(1,zc_min(253,guysbuf[new_id&0xFFF].attributes[0])); i++)
2747 {
2748 enemy *e2 = new esLanmola((zfix)x,(zfix)y,new_id+0x2000,-(i<<shft));
2749 if(!guys.add(e2))
2750 {
2751 al_trace("Lanmola segment %d could not be created!\n",i+1);
2752
2753 for(int32_t j=0; j<i+1; j++)
2754 guys.del(guys.Count()-1);
2755
2756 return 0;
2757 }
2758 e2->x = x;
2759 e2->y = y;
2760
2761 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
2762
2763 }
2764 }
2765 break;
2766
2767 case eeMANHAN:
2768 new_id &= 0xFFF;
2769
2770 for(int32_t i=0; i<((!(guysbuf[new_id].attributes[1]))?4:8); i++)
2771 {
2772 if(!guys.add(new esManhandla((zfix)x,(zfix)y,new_id+0x1000,i)))
2773 {
2774 al_trace("Manhandla head %d could not be created!\n",i+1);
2775
2776 for(int32_t j=0; j<i+1; j++)
2777 {
2778 guys.del(guys.Count()-1);
2779 }
2780
2781 return 0;
2782 }
2783
2784
2785 ((enemy*)guys.spr(guys.Count()-1))->frate=guysbuf[new_id].attributes[0];
2786 }
2787
2788 break;
2789
2790 case eeGLEEOK:
2791 {
2792 /*
2793 new_id &= 0xFFF;
2794 int32_t head_cnt = zc_max(1,zc_min(254,guysbuf[new_id&0xFFF].attributes[0]));
2795 Z_scripterrlog("Gleeok head count is %d\n",head_cnt);
2796 for(int32_t i=0; i<head_cnt; i++)
2797 {
2798 //enemy *e = new esGleeok(x,y,new_id+0x1000,clk,gleeok);
2799 if(!guys.add(new esGleeok((zfix)x,(zfix)y,new_id+0x1000,c, gleeok)))
2800 {
2801 al_trace("Gleeok head %d could not be created!\n",i+1);
2802
2803 for(int32_t j=0; j<i+1; j++)
2804 {
2805 guys.del(guys.Count()-1);
2806 }
2807
2808 break;
2809 }
2810
2811 c-=guysbuf[new_id].misc4;
2812 */
2813
2814 // }
2815 }
2816 break;
2817
2818
2819 case eePATRA:
2820 {
2821 new_id &= 0xFFF;
2822 int32_t outeyes = 0;
2823 ptra = new ePatraBS((zfix)x,(zfix)y,id,clk);
2824
2825 for(int32_t i=0; i<zc_min(254,guysbuf[new_id&0xFFF].attributes[0]); i++)
2826 {
2827 if(!((guysbuf[new_id].attributes[9] &&get_qr(qr_HARDCODED_BS_PATRA))?guys.add(new esPatraBS((zfix)x,(zfix)y,new_id+0x1000,i,ptra)):guys.add(new esPatra((zfix)x,(zfix)y,new_id+0x1000,i,ptra))))
2828 {
2829 al_trace("Patra outer eye %d could not be created!\n",i+1);
2830
2831 for(int32_t j=0; j<i+1; j++)
2832 guys.del(guys.Count()-1);
2833
2834 return 0;
2835 }
2836 else
2837 outeyes++;
2838
2839
2840 }
2841
2842 for(int32_t i=0; i<zc_min(254,guysbuf[new_id&0xFFF].attributes[1]); i++)
2843 {
2844 if(!guys.add(new esPatra((zfix)x,(zfix)y,new_id+0x1000,i,ptra)))
2845 {
2846 al_trace("Patra inner eye %d could not be created!\n",i+1);
2847
2848 for(int32_t j=0; j<i+1+zc_min(254,outeyes); j++)
2849 guys.del(guys.Count()-1);
2850
2851 return 0;
2852 }
2853
2854
2855 }
2856 delete ptra;
2857 break;
2858 }
2859 }
2860
2861
2862 // TODO(crash): check that the above .add succeeded.
2863 ((enemy*)guys.spr(guys.Count()-1))->count_enemy = true;
2864 ((enemy*)guys.spr(guys.Count()-1))->stunclk = delay_timer;
2865 ((enemy*)guys.spr(guys.Count()-1))->dir = this->dir;
2866 ((enemy*)guys.spr(guys.Count()-1))->scale = this->scale;
2867 ((enemy*)guys.spr(guys.Count()-1))->angular = this->angular;
2868 ((enemy*)guys.spr(guys.Count()-1))->angle = this->angle;
2869 ((enemy*)guys.spr(guys.Count()-1))->rotation = this->rotation;
2870 ((enemy*)guys.spr(guys.Count()-1))->itemguy = this->itemguy;
2871 ((enemy*)guys.spr(guys.Count()-1))->leader = this->leader;
2872 ((enemy*)guys.spr(guys.Count()-1))->hclk = delay_timer;
2873 ((enemy*)guys.spr(guys.Count()-1))->script_spawned = this->script_spawned;
2874 ((enemy*)guys.spr(guys.Count()-1))->script_UID = this->script_UID;
2875 ((enemy*)guys.spr(guys.Count()-1))->sclk = 0;
2876
2877
2878 item_set = 0; //Do not make a drop.
2879
2880 switch(effect_type)
2881 {
2882 case -7:
2883 {
2884 weapon *w = new weapon(x,y-fakez,z,wBomb,0,wdp,0,-1,getUID(),false, 0);
2885 Lwpns.add(w);
2886 break;
2887 }
2888 case -6:
2889 {
2890 weapon *w = new weapon(x,y-fakez,z,wSBomb,0,wdp,0,-1,getUID(),false, 0);
2891 Lwpns.add(w);
2892 break;
2893 }
2894 case -5:
2895 {
2896 weapon *w = new weapon(x,y-fakez,z,wBomb,effect_type,0,0,Hero.getUID(), txsz, tysz);
2897 Lwpns.add(w);
2898 break;
2899 }
2900 case -4:
2901 {
2902 weapon *w = new weapon(x,y-fakez,z,wSBomb,effect_type,0,0,Hero.getUID(), txsz, tysz);
2903 Lwpns.add(w);
2904 break;
2905 }
2906 case -3: explode(1); break;
2907 case -2: explode(2); break;
2908 case -1: explode(0); break;
2909 case 0: break;
2910
2911 default:
2912 {
2913 //Dummy weapon function
2914 if ( effect_type > 255 ) effect_type = 0; //Sanity bound the sprite ID.
2915 weapon *w = new weapon(x,y-fakez,z,wSSparkle,effect_type,0,0,Hero.getUID(), txsz, tysz,0,0,0,0,0,0,0);
2916 Lwpns.add(w);
2917 break;
2918 }
2919 }
2920
2921
2922 yofs = -32768;
2923 switch(guysbuf[new_id&0xFFF].family)
2924 {
2925 case eeGLEEOK:
2926 {
2927 Z_scripterrlog("Replacing a gleeok.\n");
2928 enemy *tempenemy = (enemy *) guys.getByUID(parentCore);
2929 hp = -999;
2930 tempenemy->hp = -999;
2931 break;
2932
2933 }
2934 default:
2935 hp = -1000; break;
2936 }
2937 ++game->guys[(currmap*MAPSCRSNORMAL)+currscr];
2938 return 1;
2939
2940 }
2941 case edSPLIT:
2942 {
2943 for ( int32_t q = 0; q < dmisc4; q++ )
2944 {
2945 addenemy(
2946 //ex,ey,
2947 x,y,
2948 dmisc3+0x1000,-15);
2949
2950 }
2951 item_set = 0; //Do not make a drop.
2952 hp = -1000;
2953 return -1;
2954
2955 }
2956 case edSUMMON:
2957 {
2958 int32_t summon_count = (zc_oldrand()%dmisc4)+1;
2959 for ( int32_t q = 0; q < summon_count; q++ )
2960 {
2961 int32_t x2=16*((zc_oldrand()%12)+2);
2962 int32_t y2=16*((zc_oldrand()%7)+2);
2963 addenemy(
2964 x2,y2,
2965 dmisc3+0x1000,-15);
2966
2967 }
2968 sfx(get_qr(qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE,pan(int32_t(x)));
2969 return -1;
2970
2971 }
2972
2973 case edEXPLODESMALL:
2974 {
2975 weapon *ew=new weapon(x,y-fakez,z, ewBomb, 0, dmisc4, dir,-1,getUID(),false);
2976 Ewpns.add(ew);
2977 item_set = 0; //Should we make a drop?
2978 hp = -1000;
2979 return -1;
2980 }
2981
2982
2983 case edEXPLODEHARMLESS:
2984 {
2985 weapon *ew=new weapon(x,y-fakez,z, ewSBomb, 0, dmisc4, dir,-1,getUID(),false);
2986 Ewpns.add(ew);
2987 ew->hyofs = -32768;
2988 item_set = 0; //Should we make a drop?
2989 hp = -1000;
2990 return -1;
2991 }
2992
2993
2994 case edEXPLODELARGE:
2995 {
2996 weapon *ew=new weapon(x,y-fakez,z, ewSBomb, 0, dmisc4, dir,-1,getUID(),false);
2997 Ewpns.add(ew);
2998
2999 hp = -1000;
3000 return -1;
3001 }
3002
3003
3004 case edTRIGGERSECRETS:
3005 {
3006 hidden_entrance(0, true, false, -4);
3007 return -1;
3008 }
3009
3010 case edSTUNORCHINK:
3011
3/4
✓ Branch 0 taken 1119 times.
✓ Branch 1 taken 1056 times.
✓ Branch 2 taken 1119 times.
✗ Branch 3 not taken.
3701 if (stunclk && get_qr(qr_NO_STUNLOCK))
3012 {
3013 sfx(WAV_CHINK,pan(int32_t(x)));
3014 return 1;
3015 }
3016
2/2
✓ Branch 0 taken 649 times.
✓ Branch 1 taken 1526 times.
2175 else if(*power <= 0)
3017 {
3018 649 sfx(WAV_CHINK,pan(int32_t(x)));
3019 649 return 1;
3020 }
3021 [[fallthrough]];
3022
3023 case edSTUNORIGNORE:
3024
3/4
✓ Branch 0 taken 1952 times.
✓ Branch 1 taken 1505 times.
✓ Branch 2 taken 1952 times.
✗ Branch 3 not taken.
5959 if (stunclk && get_qr(qr_NO_STUNLOCK))
3025 {
3026 sfx(WAV_CHINK,pan(int32_t(x)));
3027 return 1;
3028 }
3029
2/2
✓ Branch 0 taken 955 times.
✓ Branch 1 taken 2502 times.
3457 else if(*power <= 0)
3030 955 return 0;
3031 [[fallthrough]];
3032
3033 case edSTUNONLY:
3034
7/10
✓ Branch 0 taken 4364 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4364 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4364 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3817 times.
✓ Branch 7 taken 547 times.
✓ Branch 8 taken 4043 times.
✓ Branch 9 taken 321 times.
4364 if((wpnId==wFire || wpnId==wBomb || wpnId==wSBomb || wpnId==wHookshot || wpnId==wSword) && stunclk>=159)
3035 {
3036 // Z_message("enemy::defend(), edSTUNONLY found a weapon of type FIRE, BOMB, SBOMB, HOOKSHOT, or SWORD:, with wpnId: \n", wpnId);
3037 321 return 1;
3038 }
3039
3/4
✓ Branch 0 taken 3118 times.
✓ Branch 1 taken 925 times.
✓ Branch 2 taken 3118 times.
✗ Branch 3 not taken.
4043 if (stunclk && get_qr(qr_NO_STUNLOCK))
3040 {
3041 sfx(WAV_CHINK,pan(int32_t(x)));
3042 return 1;
3043 }
3044 else
3045 {
3046 4043 stunclk=160;
3047 4043 sfx(WAV_EHIT,pan(int32_t(x)));
3048
3049 4043 return 1;
3050 }
3051
3052 case edCHINKL1:
3053 if(*power >= 1*game->get_hero_dmgmult()) break;
3054 [[fallthrough]];
3055 case edCHINKL2:
3056
2/2
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 61 times.
113 if(*power >= 2*game->get_hero_dmgmult()) break;
3057 [[fallthrough]];
3058 case edCHINKL4:
3059
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 110 times.
190 if(*power >= 4*game->get_hero_dmgmult()) break;
3060 [[fallthrough]];
3061 case edCHINKL6:
3062
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if(*power >= 6*game->get_hero_dmgmult()) break;
3063 [[fallthrough]];
3064 case edCHINKL8:
3065
2/2
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 111 times.
154 if(*power >= 8*game->get_hero_dmgmult()) break;
3066 [[fallthrough]];
3067 case edCHINKL10:
3068
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if(*power >= 10*game->get_hero_dmgmult()) break;
3069 [[fallthrough]];
3070 case edCHINK:
3071 1056 sfx(WAV_CHINK,pan(int32_t(x)));
3072 1056 return 1;
3073
3074 case edIGNOREL1:
3075 if(*power > 0) break;
3076 [[fallthrough]];
3077
3078 case edIGNORE:
3079 17324 return 0;
3080
3081 case ed1HKO:
3082 492 *power = hp;
3083 492 return -2;
3084
3085 case ed2x:
3086 {
3087
1/2
✓ Branch 0 taken 71 times.
✗ Branch 1 not taken.
71 *power = zc_max(1,*power*2);
3088 //int32_t pow = *power;
3089 //*power = vbound((pow*2),0,214747);
3090 71 return -1;
3091 }
3092 case ed3x:
3093 {
3094 *power = zc_max(1,*power*3);
3095 //int32_t pow = *power;
3096 //*power = vbound((pow*3),0,214747);
3097 return -1;
3098 }
3099
3100 case ed4x:
3101 {
3102 *power = zc_max(1,*power*4);
3103 //int32_t pow = *power;
3104 //*power = vbound((pow*4),0,214747);
3105 return -1;
3106 }
3107
3108
3109 case edHEAL:
3110 { //Probably needs its own function, or routine in the damage functuon to heal if power is negative.
3111 //int32_t pow = *power;
3112 //*power = vbound((pow*-1),0,214747);
3113 //break;
3114
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 158 times.
158 *power = zc_min(0,*power*-1);
3115 158 return -1;
3116 }
3117 /*
3118 case edLEVELDAMAGE:
3119 {
3120 int32_t pow = *power;
3121 int32_t lvl = *level;
3122 *power = vbound((pow*lvl),0,214747);
3123 break;
3124 }
3125 case edLEVELREDUCTION:
3126 {
3127 int32_t pow = *power;
3128 int32_t lvl = *level;
3129 *power = vbound((pow/lvl),0,214747);
3130 break;
3131 }
3132 */
3133
3134 case edQUARTDAMAGE:
3135
2/2
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 3 times.
105 *power = zc_max(1,*power/2);
3136
3137 [[fallthrough]];
3138 case edHALFDAMAGE:
3139
2/2
✓ Branch 0 taken 832 times.
✓ Branch 1 taken 156 times.
988 *power = zc_max(1,*power/2);
3140 988 break;
3141
3142 case edSWITCH:
3143 {
3144
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(Hero.switchhookclk) return 0; //Already switching!
3145
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 switch(family)
3146 {
3147 case eeAQUA: case eeMOLD: case eeDONGO: case eeMANHAN: case eeGLEEOK:
3148 case eeDIG: case eeGHOMA: case eeLANM: case eePATRA: case eeGANON:
3149 return 0;
3150 }
3151 4 hooked_combopos = -1;
3152 4 hooked_layerbits = 0;
3153 4 switching_object = this;
3154 4 switch_hooked = true;
3155 4 Hero.doSwitchHook(game->get_switchhookstyle());
3156
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(QMisc.miscsfx[sfxSWITCHED])
3157 sfx(QMisc.miscsfx[sfxSWITCHED],int32_t(x));
3158 4 return 1;
3159 }
3160
3161 case 0:
3162 {
3163
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93072 times.
93072 if(edef == edefSwitchHook)
3164 return -1;
3165
6/6
✓ Branch 0 taken 19532 times.
✓ Branch 1 taken 73540 times.
✓ Branch 2 taken 58 times.
✓ Branch 3 taken 19474 times.
✓ Branch 4 taken 32 times.
✓ Branch 5 taken 26 times.
93072 if (stunclk && get_qr(qr_NO_STUNLOCK) && *power == 0)
3166 {
3167 26 sfx(WAV_CHINK,pan(int32_t(x)));
3168 26 return 1;
3169 }
3170
3171 }
3172 93046 }
3173
3174 94209 return -1;
3175 125881 }
3176
3177 125881 int32_t enemy::defendNewInt(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable, weapon* w)
3178 {
3179
1/2
✓ Branch 0 taken 125881 times.
✗ Branch 1 not taken.
125881 int wuid = w?w->getUID():0;
3180
1/2
✓ Branch 0 taken 125881 times.
✗ Branch 1 not taken.
125881 bool fakeweap = (w && !Lwpns.getByUID(wuid));
3181
3182
1/2
✓ Branch 0 taken 125881 times.
✗ Branch 1 not taken.
125881 if(fakeweap)
3183 Lwpns.add(w);
3184 125881 std::vector<int32_t> &ev = FFCore.eventData;
3185 125881 ev.clear();
3186 125881 ev.push_back(*power*10000);
3187 125881 ev.push_back(edef*10000);
3188 125881 ev.push_back(unblockable*10000);
3189 125881 ev.push_back(wpnId*10000);
3190 125881 ev.push_back(0);
3191 125881 ev.push_back(getUID());
3192 125881 ev.push_back(wuid);
3193
3194 125881 throwGenScriptEvent(GENSCR_EVENT_ENEMY_HIT1);
3195 125881 *power = ev[0]/10000;
3196 125881 edef = ev[1]/10000;
3197 125881 unblockable = byte(ev[2]/10000);
3198 125881 wpnId = ev[3] / 10000;
3199 125881 bool nullify = ev[4]!=0;
3200 125881 ev.clear();
3201 125881 int ret = 0;
3202
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125881 times.
125881 if(!nullify)
3203 {
3204 125881 ret = defendNew(wpnId, power, edef, unblockable);
3205
2/2
✓ Branch 0 taken 32805 times.
✓ Branch 1 taken 93076 times.
125881 if(ret == -1)
3206 {
3207 93076 ev.push_back(*power*10000);
3208 93076 ev.push_back(edef*10000);
3209 93076 ev.push_back(unblockable*10000);
3210 93076 ev.push_back(wpnId*10000);
3211 93076 ev.push_back(0);
3212 93076 ev.push_back(getUID());
3213
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93076 times.
93076 ev.push_back(w?w->getUID():0);
3214
3215 93076 throwGenScriptEvent(GENSCR_EVENT_ENEMY_HIT2);
3216 93076 *power = ev[0]/10000;
3217 93076 nullify = ev[4]!=0;
3218 93076 ev.clear();
3219 93076 }
3220 125881 }
3221
1/2
✓ Branch 0 taken 125881 times.
✗ Branch 1 not taken.
125881 if(fakeweap)
3222 Lwpns.remove(w);
3223
3224
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125881 times.
125881 return nullify ? 0 : ret;
3225 }
3226
3227 99078 int32_t enemy::defenditemclassNew(int32_t wpnId, int32_t *power, weapon *w, weapon* realweap)
3228 {
3229
2/2
✓ Branch 0 taken 98501 times.
✓ Branch 1 taken 577 times.
99078 if(!realweap) realweap = w;
3230 99078 int32_t wid = getWeaponID(w);
3231
3232 99078 int32_t edef = resolveEnemyDefence(w);
3233
2/2
✓ Branch 0 taken 5855 times.
✓ Branch 1 taken 93223 times.
99078 if(QHeader.zelda_version > 0x250)
3234 5855 return defendNewInt(wid, power, edef, w->unblockable, realweap);
3235
2/3
✓ Branch 0 taken 993 times.
✓ Branch 1 taken 92230 times.
✗ Branch 2 not taken.
93223 switch(wid)
3236 {
3237 case wScript1: case wScript2: case wScript3: case wScript4: case wScript5:
3238 case wScript6: case wScript7: case wScript8: case wScript9: case wScript10:
3239 993 return defend(wpnId, power, edefSCRIPT);
3240
3241 case wWhistle:
3242 return -1;
3243
3244 default:
3245 92230 return defendNewInt(wid, power, edef, w->unblockable, realweap);
3246 }
3247 99078 }
3248
3249
3250 // Check defenses without actually acting on them.
3251 27402 bool enemy::candamage(int32_t power, int32_t edef, byte unblockable)
3252 {
3253
4/10
✓ Branch 0 taken 15409 times.
✓ Branch 1 taken 11050 times.
✓ Branch 2 taken 469 times.
✓ Branch 3 taken 474 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
27402 switch(defense[edef])
3254 {
3255 case edSTUNONLY:
3256 474 return false;
3257 case edSTUNORCHINK:
3258 case edCHINK:
3259 15409 return unblockable&WPNUNB_BLOCK;
3260 case edSTUNORIGNORE:
3261 case edIGNORE:
3262 11050 return unblockable&WPNUNB_IGNR;
3263
3264 case edIGNOREL1:
3265 return (unblockable&WPNUNB_IGNR) || power >= 1*game->get_hero_dmgmult();
3266 case edCHINKL1:
3267 return (unblockable&WPNUNB_BLOCK) || power >= 1*game->get_hero_dmgmult();
3268
3269 case edCHINKL2:
3270 return (unblockable&WPNUNB_BLOCK) || power >= 2*game->get_hero_dmgmult();
3271
3272 case edCHINKL4:
3273 return (unblockable&WPNUNB_BLOCK) || power >= 4*game->get_hero_dmgmult();
3274
3275 case edCHINKL6:
3276 return (unblockable&WPNUNB_BLOCK) || power >= 6*game->get_hero_dmgmult();
3277
3278 case edCHINKL8:
3279 return (unblockable&WPNUNB_BLOCK) || power >= 8*game->get_hero_dmgmult();
3280 }
3281
3282 469 return true;
3283 27402 }
3284
3285 // Do we do damage?
3286 // 0: takehit returns 0
3287 // 1: takehit returns 1
3288 // -1: do damage
3289 993 int32_t enemy::defend(int32_t wpnId, int32_t *power, int32_t edef)
3290 {
3291
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 993 times.
993 if(shieldCanBlock)
3292 {
3293 switch(defense[edef])
3294 {
3295 case edIGNORE:
3296 return 0;
3297 case edIGNOREL1:
3298 case edSTUNORIGNORE:
3299 if(*power <= 0)
3300 return 0;
3301 }
3302
3303 sfx(WAV_CHINK,pan(int32_t(x)));
3304 return 1;
3305 }
3306
3307
3/22
✓ Branch 0 taken 186 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 800 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 7 times.
993 switch(defense[edef])
3308 {
3309 case edSTUNORCHINK:
3310 if(*power <= 0)
3311 {
3312 sfx(WAV_CHINK,pan(int32_t(x)));
3313 return 1;
3314 }
3315
3316 [[fallthrough]];
3317 case edSTUNORIGNORE:
3318 if(*power <= 0)
3319 return 0;
3320
3321 [[fallthrough]];
3322 case edSTUNONLY:
3323 if((wpnId==wFire || wpnId==wBomb || wpnId==wSBomb || wpnId==wHookshot || wpnId==wSword) && stunclk>=159)
3324 return 1;
3325
3326 stunclk=160;
3327 sfx(WAV_EHIT,pan(int32_t(x)));
3328 return 1;
3329
3330 case edFREEZE:
3331 frozenclock=-1;
3332 //sfx(WAV_FREEZE,pan(int32_t(x)));
3333 return 1;
3334
3335 case edCHINKL1:
3336 if(*power >= 1*game->get_hero_dmgmult()) break;
3337 [[fallthrough]];
3338 case edCHINKL2:
3339 if(*power >= 2*game->get_hero_dmgmult()) break;
3340 [[fallthrough]];
3341 case edCHINKL4:
3342 if(*power >= 4*game->get_hero_dmgmult()) break;
3343 [[fallthrough]];
3344 case edCHINKL6:
3345 if(*power >= 6*game->get_hero_dmgmult()) break;
3346 [[fallthrough]];
3347 case edCHINKL8:
3348 if(*power >= 8*game->get_hero_dmgmult()) break;
3349 [[fallthrough]];
3350 case edCHINKL10:
3351 if(*power >= 10*game->get_hero_dmgmult()) break;
3352 [[fallthrough]];
3353 case edCHINK:
3354 sfx(WAV_CHINK,pan(int32_t(x)));
3355 return 1;
3356 case edTRIGGERSECRETS:
3357 hidden_entrance(0, true, false, -4);
3358 break;
3359
3360 case edIGNOREL1:
3361 if(*power > 0) break;
3362 [[fallthrough]];
3363 case edIGNORE:
3364 800 return 0;
3365
3366 case ed1HKO:
3367 *power = hp;
3368 return -2;
3369
3370 case ed2x:
3371 {
3372 *power = zc_max(1,*power*2);
3373 //int32_t pow = *power;
3374 //*power = vbound((pow*2),0,214747);
3375 return -1;
3376 }
3377 case ed3x:
3378 {
3379 *power = zc_max(1,*power*3);
3380 //int32_t pow = *power;
3381 //*power = vbound((pow*3),0,214747);
3382 return -1;
3383 }
3384
3385 case ed4x:
3386 {
3387 *power = zc_max(1,*power*4);
3388 //int32_t pow = *power;
3389 //*power = vbound((pow*4),0,214747);
3390 return -1;
3391 }
3392
3393
3394 case edHEAL:
3395 { //Probably needs its own function, or routine in the damage functuon to heal if power is negative.
3396 //int32_t pow = *power;
3397 //*power = vbound((pow*-1),0,214747);
3398 //break;
3399 *power = zc_min(0,*power*-1);
3400 return -1;
3401 }
3402 /*
3403 case edLEVELDAMAGE:
3404 {
3405 int32_t pow = *power;
3406 int32_t lvl = *level;
3407 *power = vbound((pow*lvl),0,214747);
3408 break;
3409 }
3410 case edLEVELREDUCTION:
3411 {
3412 int32_t pow = *power;
3413 int32_t lvl = *level;
3414 *power = vbound((pow/lvl),0,214747);
3415 break;
3416 }
3417 */
3418
3419
3420 case edQUARTDAMAGE:
3421
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 *power = zc_max(1,*power/2);
3422
3423 [[fallthrough]];
3424 case edHALFDAMAGE:
3425
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 *power = zc_max(1,*power/2);
3426 7 break;
3427 }
3428
3429 193 return -1;
3430 993 }
3431
3432 // Defend against a particular item class.
3433 int32_t enemy::defenditemclass(int32_t wpnId, int32_t *power)
3434 {
3435 int32_t def=-1;
3436
3437 switch(wpnId)
3438 {
3439 // These first 2 are only used by Gohma... enemy::takehit() has complicated stun-calculation code for these.
3440 case wBrang:
3441 def = defend(wpnId, power, edefBRANG);
3442 break;
3443
3444 case wHookshot:
3445 def = defend(wpnId, power, edefHOOKSHOT);
3446 break;
3447
3448 // Anyway...
3449 case wBomb:
3450 def = defend(wpnId, power, edefBOMB);
3451 break;
3452
3453 case wSBomb:
3454 def = defend(wpnId, power, edefSBOMB);
3455 break;
3456
3457 case wArrow:
3458 def = defend(wpnId, power, edefARROW);
3459 break;
3460
3461 case wFire:
3462 def = defend(wpnId, power, edefFIRE);
3463 break;
3464
3465 case wWand:
3466 def = defend(wpnId, power, edefWAND);
3467 break;
3468
3469 case wMagic:
3470 def = defend(wpnId, power, edefMAGIC);
3471 break;
3472
3473 case wHammer:
3474 def = defend(wpnId, power, edefHAMMER);
3475 break;
3476
3477 case wSword:
3478 def = defend(wpnId, power, edefSWORD);
3479 break;
3480
3481 case wBeam:
3482 def = defend(wpnId, power, edefBEAM);
3483 break;
3484
3485 case wRefBeam:
3486 def = defend(wpnId, power, edefREFBEAM);
3487 break;
3488
3489 case wRefMagic:
3490 def = defend(wpnId, power, edefREFMAGIC);
3491 break;
3492
3493 case wRefFireball:
3494 def = defend(wpnId, power, edefREFBALL);
3495 break;
3496
3497 case wRefRock:
3498 def = defend(wpnId, power, edefREFROCK);
3499 break;
3500
3501 case wStomp:
3502 def = defend(wpnId, power, edefSTOMP);
3503 break;
3504
3505 case wCByrna:
3506 def = defend(wpnId, power, edefBYRNA);
3507 break;
3508
3509 case wScript1:
3510 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT01);
3511 else def = defend(wpnId, power, edefSCRIPT);
3512 break;
3513
3514 case wScript2:
3515 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT02);
3516 else def = defend(wpnId, power, edefSCRIPT);
3517 break;
3518
3519 case wScript3:
3520 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT03);
3521 else def = defend(wpnId, power, edefSCRIPT);
3522 break;
3523
3524 case wScript4:
3525 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT04);
3526 else def = defend(wpnId, power, edefSCRIPT);
3527 break;
3528
3529 case wScript5:
3530 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT05);
3531 else def = defend(wpnId, power, edefSCRIPT);
3532 break;
3533
3534 case wScript6:
3535 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT06);
3536 else def = defend(wpnId, power, edefSCRIPT);
3537 break;
3538
3539 case wScript7:
3540 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT07);
3541 else def = defend(wpnId, power, edefSCRIPT);
3542 break;
3543
3544 case wScript8:
3545 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT08);
3546 else def = defend(wpnId, power, edefSCRIPT);
3547 break;
3548
3549 case wScript9:
3550 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT09);
3551 else def = defend(wpnId, power, edefSCRIPT);
3552 break;
3553
3554 case wScript10:
3555 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT10);
3556 else def = defend(wpnId, power, edefSCRIPT);
3557 break;
3558
3559 case wWhistle:
3560 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefWhistle);
3561 else break;
3562 break;
3563
3564 case wRefArrow:
3565 def = defend(wpnId, power, edefREFARROW);
3566 break;
3567 case wRefFire:
3568 def = defend(wpnId, power, edefREFFIRE);
3569 break;
3570 case wRefFire2:
3571 def = defend(wpnId, power, edefREFFIRE2);
3572 break;
3573
3574 //!ZoriaRPG : We need some special cases here, to ensure that old script defs don;t break.
3575 //Probably best to do this from the qest file, loading the values of Script(generic) into each
3576 //of the ten if the quest version is lower than N.
3577 //Either that, or we need a boolean flag to set int32_t he enemy editor, or by ZScript that changes this behaviour.
3578 //such as bool UseSeparatedScriptDefences. hah.
3579 default:
3580 //if(wpnId>=wScript1 && wpnId<=wScript10)
3581 // {
3582 // def = defend(wpnId, power, edefSCRIPT);
3583 // }
3584 // }
3585
3586 break;
3587 }
3588
3589 return def;
3590 }
3591
3592 // take damage or ignore it
3593 // -1: damage (if any) dealt
3594 // 1: blocked
3595 // 0: weapon passes through unhindered
3596 264490 int32_t enemy::takehit(weapon *w, weapon* realweap)
3597 {
3598
2/4
✓ Branch 0 taken 264490 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 264490 times.
264490 if(fallclk||drownclk) return 0;
3599
2/2
✓ Branch 0 taken 69416 times.
✓ Branch 1 taken 195074 times.
264490 if(!realweap) realweap = w;
3600 264490 int32_t wpnId = w->id;
3601 264490 int32_t power = w->power;
3602 264490 int32_t wpnx = w->x;
3603 264490 int32_t wpny = w->y;
3604 264490 int32_t enemyHitWeapon = w->parentitem;
3605 int32_t wpnDir;
3606 264490 int32_t parent_item = w->parentitem;
3607
3608
2/2
✓ Branch 0 taken 264375 times.
✓ Branch 1 taken 115 times.
264490 if ( w->useweapon > 0 /*&& wpnId != wWhistle*/ )
3609 {
3610 115 wpnId = w->useweapon;
3611 115 }
3612
3613 // If it's a boomerang that just bounced, use the opposite direction;
3614 // otherwise, it might bypass a shield. This probably won't handle
3615 // every case correctly, but it's better than having shields simply
3616 // not work against boomerangs.
3617
8/8
✓ Branch 0 taken 25075 times.
✓ Branch 1 taken 239415 times.
✓ Branch 2 taken 15580 times.
✓ Branch 3 taken 9495 times.
✓ Branch 4 taken 14362 times.
✓ Branch 5 taken 1218 times.
✓ Branch 6 taken 3306 times.
✓ Branch 7 taken 11056 times.
264490 if(w->id==wBrang && w->misc==1 && w->clk2>=256 && w->clk2<264)
3618 11056 wpnDir = oppositeDir[w->dir];
3619 else
3620 253434 wpnDir = w->dir;
3621
3622
5/8
✓ Branch 0 taken 264490 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 264490 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 264490 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 8188 times.
✓ Branch 7 taken 271948 times.
264490 if(dying || clk<0 || hclk>0 || superman)
3623 8188 return 0;
3624
3625 //Prevent boomerang from writing to hitby[] for more than one frame.
3626 //This also prevents stunlock.
3627 //if ( stunclk > 0 ) return 0;
3628 //this needs a rule for boomerangs that cannot stunlock!
3629 //further, bouncing weapons should probably SFX_CHINK and bounce here.
3630 //sigh.
3631
3632 271948 int32_t ret = -1;
3633
3634 // This obscure quest rule...
3635
5/6
✓ Branch 0 taken 91726 times.
✓ Branch 1 taken 180222 times.
✓ Branch 2 taken 88223 times.
✓ Branch 3 taken 3503 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 88223 times.
271948 if(get_qr(qr_BOMBDARKNUTFIX) && (wpnId==wBomb || wpnId==wSBomb))
3636 {
3637 double _MSVC2022_tmp1, _MSVC2022_tmp2;
3638 3503 double ddir=atan2_MSVC2022_FIX(double(wpny-y),double(x-wpnx));
3639 3503 wpnDir=zc_oldrand()&3;
3640
3641
4/4
✓ Branch 0 taken 467 times.
✓ Branch 1 taken 3036 times.
✓ Branch 2 taken 278 times.
✓ Branch 3 taken 189 times.
3503 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
3642 {
3643 189 wpnDir=down;
3644 189 }
3645
4/4
✓ Branch 0 taken 563 times.
✓ Branch 1 taken 2751 times.
✓ Branch 2 taken 278 times.
✓ Branch 3 taken 285 times.
3314 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
3646 {
3647 285 wpnDir=right;
3648 285 }
3649
4/4
✓ Branch 0 taken 2342 times.
✓ Branch 1 taken 687 times.
✓ Branch 2 taken 278 times.
✓ Branch 3 taken 2064 times.
3029 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/4)))
3650 {
3651 2064 wpnDir=up;
3652 2064 }
3653 else
3654 {
3655 965 wpnDir=left;
3656 }
3657 3503 }
3658
3659 271948 int32_t xdir = dir;
3660 271948 shieldCanBlock=false;
3661
3662
4/4
✓ Branch 0 taken 260668 times.
✓ Branch 1 taken 11280 times.
✓ Branch 2 taken 2767 times.
✓ Branch 3 taken 257901 times.
272676 if(!(w->unblockable&WPNUNB_BLOCK)&&((wpnId==wHookshot && hitshield(wpnx, wpny, xdir))
3663
6/6
✓ Branch 0 taken 18250 times.
✓ Branch 1 taken 15483 times.
✓ Branch 2 taken 26192 times.
✓ Branch 3 taken 247192 times.
✓ Branch 4 taken 58 times.
✓ Branch 5 taken 247134 times.
260668 || ((flags&guy_shield_front && wpnDir==(xdir^down)) || (flags&guy_shield_back && wpnDir==(xdir^up)) ||
3664
4/4
✓ Branch 0 taken 984 times.
✓ Branch 1 taken 246150 times.
✓ Branch 2 taken 728 times.
✓ Branch 3 taken 245422 times.
247134 (flags&guy_shield_left && wpnDir==(xdir^(xdir&2?right:left))) || (flags&guy_shield_right && wpnDir==(xdir^(dir&2?left:right)))))
3665 )
3666 // The hammer should already be dealt with by subclasses (Walker etc.)
3667 {
3668
10/10
✓ Branch 0 taken 864 times.
✓ Branch 1 taken 380 times.
✓ Branch 2 taken 29 times.
✓ Branch 3 taken 680 times.
✓ Branch 4 taken 5756 times.
✓ Branch 5 taken 338 times.
✓ Branch 6 taken 13 times.
✓ Branch 7 taken 11 times.
✓ Branch 8 taken 153 times.
✓ Branch 9 taken 1488 times.
46212 switch(wpnId)
3669 {
3670 // Weapons which shields protect against
3671 case wSword:
3672 case wWand:
3673
2/2
✓ Branch 0 taken 5754 times.
✓ Branch 1 taken 2 times.
5758 if(Hero.getCharging()>0)
3674 2 Hero.setAttackClk(Hero.getAttackClk()+1); //Cancel charging
3675
3676 [[fallthrough]];
3677 case wHookshot:
3678 case wHSHandle:
3679 case wBrang:
3680 6136 shieldCanBlock=true;
3681 6474 break;
3682
3683 case wBeam:
3684 case wRefBeam:
3685 // Mirror shielded enemies!
3686 #if 0
3687 if(false /*flags&guy_mirror*/ && !get_qr(qr_SWORDMIRROR))
3688 {
3689 if(wpnId>wEnemyWeapons)
3690 return 0;
3691
3692 sfx(WAV_CHINK,pan(int32_t(x)));
3693 return 1;
3694 }
3695
3696 #endif
3697
3698 [[fallthrough]];
3699 case wRefRock:
3700 case wRefFireball:
3701 case wMagic:
3702 #if 0
3703 if(false /*flags&guy_mirror*/ && (wpnId!=wRefRock || get_qr(qr_REFLECTROCKS)))
3704 {
3705 sfx(WAV_CHINK,pan(int32_t(x)));
3706 return 3;
3707 }
3708
3709 #endif
3710
3711
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 367 times.
367 if(wpnId>wEnemyWeapons)
3712 return 0;
3713
3714 [[fallthrough]];
3715 case wArrow:
3716 380 case wRefArrow:
3717 default:
3718 1868 shieldCanBlock=true;
3719 1868 break;
3720
3721 // Bombs
3722 case wSBomb:
3723 case wBomb:
3724
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if (!get_qr(qr_TRUEFIXEDBOMBSHIELD)) goto hitclock;
3725 else if (!get_qr(qr_BOMBSPIERCESHIELD))
3726 {
3727 sfx(WAV_CHINK,pan(int32_t(x)));
3728 return 0;
3729 }
3730 else break;
3731
3732 // Weapons which ignore shields
3733 case wWhistle:
3734 case wHammer:
3735 153 break;
3736
3737 // Weapons which shouldn't be removed by shields
3738 case wLitBomb:
3739 case wLitSBomb:
3740 case wWind:
3741 case wPhantom:
3742 case wSSparkle:
3743 case wBait:
3744 864 return 0;
3745
3746 case wFire:
3747 case wRefFire:
3748 case wRefFire2:
3749 ;
3750 680 }
3751 8837 }
3752
3753
8/8
✓ Branch 0 taken 103171 times.
✓ Branch 1 taken 97421 times.
✓ Branch 2 taken 423 times.
✓ Branch 3 taken 270 times.
✓ Branch 4 taken 27402 times.
✓ Branch 5 taken 25029 times.
✓ Branch 6 taken 2767 times.
✓ Branch 7 taken 9056 times.
265539 switch(wpnId)
3754 {
3755 case wWhistle: //No longer completely ignore whistle weapons! -Z
3756 {
3757
3758
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 423 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
423 if ( ((itemsbuf[parent_item].flags & item_flag2) == 0) || ( parent_item == -1 ) ) //if the flag is set, or the weapon is scripted
3759 {
3760 423 return 0; break;
3761 }
3762 else
3763 {
3764 w->power = power = itemsbuf[parent_item].misc5;
3765
3766 int32_t def = defendNewInt(wpnId, &power, resolveEnemyDefence(w), w->unblockable, realweap);
3767
3768 if(def <= 0)
3769 {
3770 if ( def == -2 ) hp -= hp;
3771 else hp -= power;
3772 return def;
3773 }
3774 break;
3775 }
3776 break;
3777 }
3778
3779 case wPhantom:
3780 270 return 0;
3781
3782 case wLitBomb:
3783 case wLitSBomb:
3784 case wBait:
3785 case wWind:
3786 case wSSparkle:
3787 103171 return 0;
3788
3789 case wFSparkle:
3790
3791 // Only take sparkle damage if the sparkle's parent item is not
3792 // defended against.
3793
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27402 times.
27402 if(enemyHitWeapon > -1)
3794 {
3795 27402 int32_t p = 0;
3796 27402 int32_t f = itemsbuf[enemyHitWeapon].family;
3797
3798
1/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 27402 times.
27402 switch(f)
3799 {
3800 case itype_arrow:
3801 if(!candamage(p, edefARROW, w->unblockable)) return 0;
3802
3803 break;
3804
3805 case itype_cbyrna:
3806 if(!candamage(p, edefBYRNA, w->unblockable)) return 0;
3807
3808 break;
3809
3810 case itype_brang:
3811
2/2
✓ Branch 0 taken 469 times.
✓ Branch 1 taken 26933 times.
27402 if(!candamage(p, edefBRANG, w->unblockable)) return 0;
3812
3813 469 break;
3814
3815 default:
3816 return 0;
3817 }
3818 469 }
3819
3820 469 wpnId = wSword;
3821 469 power = game->get_hero_dmgmult()>>1;
3822 469 goto fsparkle;
3823 break;
3824
3825 case wBrang:
3826 {
3827 //int32_t def = defendNew(wpnId, &power, edefBRANG, w);
3828 25029 int32_t def = defendNewInt(wpnId, &power, resolveEnemyDefence(w), w->unblockable, realweap);
3829 //preventing stunlock might be best, here. -Z
3830
2/2
✓ Branch 0 taken 5471 times.
✓ Branch 1 taken 19558 times.
25029 if(def >= 0) return def;
3831
3832 // Not hurt by 0-damage weapons
3833
2/2
✓ Branch 0 taken 3184 times.
✓ Branch 1 taken 16374 times.
19558 if(!(flags & guy_bhit))
3834 {
3835 16374 stunclk=160;
3836
3837
3/4
✓ Branch 0 taken 16374 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1305 times.
✓ Branch 3 taken 15069 times.
16374 if(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_brang))
3838 {
3839
1/2
✓ Branch 0 taken 1305 times.
✗ Branch 1 not taken.
1305 hp -= (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_brang))*game->get_hero_dmgmult();
3840 1305 goto hitclock;
3841 }
3842
3843 15069 break;
3844 }
3845
3846
2/2
✓ Branch 0 taken 391 times.
✓ Branch 1 taken 2793 times.
3184 if(!power)
3847
1/2
✓ Branch 0 taken 2793 times.
✗ Branch 1 not taken.
2793 hp-=(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].fam_type : current_item(itype_brang))*game->get_hero_dmgmult();
3848 else
3849 391 hp-=power;
3850
3851 3184 goto hitclock;
3852 }
3853
3854 case wHookshot:
3855 {
3856 //int32_t def = defendNew(wpnId, &power, edefHOOKSHOT,w);
3857 2767 int32_t def = defendNewInt(wpnId, &power, resolveEnemyDefence(w), w->unblockable, realweap);
3858
3859
2/2
✓ Branch 0 taken 994 times.
✓ Branch 1 taken 1773 times.
2767 if(def >= 0) return def;
3860
3861
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1773 times.
1773 bool swgrab = switch_hooked || w->family_class == itype_switchhook;
3862
3/4
✓ Branch 0 taken 1773 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1625 times.
✓ Branch 3 taken 148 times.
1773 if(swgrab || !(flags & guy_bhit))
3863 {
3864
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1625 times.
1625 if(!swgrab)
3865 1625 stunclk=160;
3866
3867
3/4
✓ Branch 0 taken 1625 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 549 times.
✓ Branch 3 taken 1076 times.
1625 if(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_hookshot))
3868 {
3869
1/2
✓ Branch 0 taken 549 times.
✗ Branch 1 not taken.
549 hp -= (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_hookshot))*game->get_hero_dmgmult();
3870 549 goto hitclock;
3871 }
3872
3873 1076 break;
3874 }
3875
3876
3/4
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 103 times.
✓ Branch 2 taken 103 times.
✗ Branch 3 not taken.
148 if(!power) hp-=(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].fam_type : current_item(itype_hookshot))*game->get_hero_dmgmult();
3877 else
3878 45 hp-=power;
3879
3880 148 goto hitclock;
3881 }
3882 break;
3883
3884 case wHSHandle:
3885 {
3886
3/4
✓ Branch 0 taken 9056 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 523 times.
✓ Branch 3 taken 8533 times.
9056 if(itemsbuf[enemyHitWeapon>-1 ? enemyHitWeapon : current_item_id(itype_hookshot)].flags & item_flag1)
3887 523 return 0;
3888
3889
3/4
✓ Branch 0 taken 6093 times.
✓ Branch 1 taken 2440 times.
✓ Branch 2 taken 2440 times.
✗ Branch 3 not taken.
8533 bool ignorehookshot = ((defense[edefHOOKSHOT] == edIGNORE) || ((defense[edefHOOKSHOT] == edIGNOREL1 || defense[edefHOOKSHOT] == edSTUNORIGNORE)
3890
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2440 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2440 && (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_hookshot)) <= 0));
3891
3892 // Peahats, Darknuts, Aquamentuses, Pols Voices, Wizzrobes, Manhandlas
3893
6/8
✓ Branch 0 taken 2787 times.
✓ Branch 1 taken 5746 times.
✓ Branch 2 taken 2787 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2787 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 502 times.
✓ Branch 7 taken 2285 times.
10245 if(!(family==eePEAHAT || family==eeAQUA || family==eeMANHAN || (family==eeWIZZ && !ignorehookshot)
3894
6/6
✓ Branch 0 taken 3375 times.
✓ Branch 1 taken 2873 times.
✓ Branch 2 taken 1771 times.
✓ Branch 3 taken 3889 times.
✓ Branch 4 taken 1712 times.
✓ Branch 5 taken 2177 times.
2787 || (family==eeWALK && dmisc9==e9tPOLSVOICE) || (family==eeWALK && flags&(guy_shield_back|guy_shield_front|guy_shield_left|guy_shield_right))))
3895 2177 return 0;
3896
3897 12102 power = game->get_hero_dmgmult();
3898 12571 }
3899
3900 fsparkle:
3901
3902 [[fallthrough]];
3903 default:
3904 // Work out the defenses!
3905 {
3906 98500 int32_t def = defenditemclassNew(wpnId, &power, w, realweap);
3907
3908
2/2
✓ Branch 0 taken 26491 times.
✓ Branch 1 taken 72009 times.
98500 if(def >= 0)
3909 26491 return def;
3910
2/2
✓ Branch 0 taken 71549 times.
✓ Branch 1 taken 460 times.
72009 else if(def == -2)
3911 {
3912 460 ret = 0;
3913 460 }
3914 }
3915
3916
2/2
✓ Branch 0 taken 72007 times.
✓ Branch 1 taken 2 times.
144018 if(!power)
3917 {
3918
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(flags & guy_bhit)
3919 2 hp-=1;
3920 else
3921 {
3922 // Don't make a long chain of 'stun' hits
3923 if((wpnId==wFire || wpnId==wBomb || wpnId==wSBomb || wpnId==wSword) && stunclk>0)
3924 return 1;
3925
3926
3927 if(!switch_hooked)
3928 stunclk=160;
3929 break;
3930 }
3931 2 }
3932 72007 else hp-=power;
3933
3934 hitclock:
3935 77206 hclk=33;
3936
3937 // Use w->dir instead of wpnDir to make sure boomerangs don't push enemies the wrong way
3938
2/2
✓ Branch 0 taken 34517 times.
✓ Branch 1 taken 42689 times.
77206 if((dir&2)==(w->dir&2))
3939 {
3940 42689 sclk=(w->dir<<8)+16;
3941 42689 }
3942 77206 }
3943
3944
5/6
✓ Branch 0 taken 73793 times.
✓ Branch 1 taken 19558 times.
✓ Branch 2 taken 21969 times.
✓ Branch 3 taken 71382 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 21969 times.
93351 if(((wpnId==wBrang) || (get_qr(qr_NOFLASHDEATH))) && (hp<=0 && !immortal))
3945 {
3946 21969 fading=fade_blue_poof;
3947 21969 }
3948
3949
6/6
✓ Branch 0 taken 88410 times.
✓ Branch 1 taken 4941 times.
✓ Branch 2 taken 46745 times.
✓ Branch 3 taken 41665 times.
✓ Branch 4 taken 2155 times.
✓ Branch 5 taken 44590 times.
93351 if ( FFCore.getQuestHeaderInfo(vZelda) > 0x250 || ( FFCore.getQuestHeaderInfo(vZelda) == 0x250 && FFCore.getQuestHeaderInfo(vBuild) > 31 )) //2.53 Gamma 2 and later
3950 {
3951
2/2
✓ Branch 0 taken 7089 times.
✓ Branch 1 taken 7 times.
7096 if( hitsfx > 0 ) //user-set hit sound.
3952 {
3953
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7089 times.
7089 if (!dying) //don't play the hit sound on death! -Z
3954 7089 sfx(hitsfx, pan(int32_t(x)));
3955 7089 }
3956 7 else sfx(WAV_EHIT, pan(int32_t(x))); //Don't play the hardcoded sound if the user sets a custom one.
3957 7096 }
3958 else //2.50.2 or earlier
3959 {
3960 86255 sfx(WAV_EHIT, pan(int32_t(x)));
3961 86255 sfx(hitsfx, pan(int32_t(x)));
3962 }
3963
2/2
✓ Branch 0 taken 93322 times.
✓ Branch 1 taken 29 times.
93351 if(family==eeGUY)
3964 29 sfx(WAV_EDEAD, pan(int32_t(x)));
3965
3966 // Penetrating weapons
3967
4/4
✓ Branch 0 taken 91490 times.
✓ Branch 1 taken 1861 times.
✓ Branch 2 taken 84591 times.
✓ Branch 3 taken 8760 times.
93351 if((wpnId==wArrow || wpnId==wBeam) && !cannotpenetrate())
3968 {
3969 8760 int32_t item=enemyHitWeapon;
3970
3971
2/2
✓ Branch 0 taken 1599 times.
✓ Branch 1 taken 7161 times.
8760 if(wpnId==wArrow)
3972 {
3973 //If we use an arrow type for the item's Weapon type, the flags differ, so we need to rely on the flags from an arrow class.
3974
5/6
✓ Branch 0 taken 1484 times.
✓ Branch 1 taken 115 times.
✓ Branch 2 taken 379 times.
✓ Branch 3 taken 1105 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 379 times.
1599 if(item>=0 && (itemsbuf[item].flags&item_flag1) && (itemsbuf[parent_item].family == itype_arrow))
3975 379 return 0;
3976
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1220 times.
1220 else if(get_qr(qr_ARROWS_ALWAYS_PENETRATE)) return 0;
3977 //if(item<0)
3978 else
3979 1220 item=current_item_id(itype_arrow);
3980 1220 }
3981
3982 else
3983 {
3984
3985 //If we use an swordbeam type for the item's Weapon type, the flags differ, so we need to rely on the flags from an arrow class.
3986
3/6
✓ Branch 0 taken 7143 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7143 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7161 if(item>=0 && (itemsbuf[item].flags&item_flag3) && (itemsbuf[parent_item].family == itype_sword))
3987 return 0;
3988
3989
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7161 times.
7161 else if(get_qr(qr_SWORDBEAMS_ALWAYS_PENETRATE)) return 0;
3990 else
3991 //if(item<0)
3992 7161 item=current_item_id(itype_sword);
3993 }
3994 8381 }
3995
3996 92972 return ret;
3997 268856 }
3998
3999 61504697 bool enemy::dont_draw()
4000 {
4001
6/6
✓ Branch 0 taken 61041911 times.
✓ Branch 1 taken 462786 times.
✓ Branch 2 taken 60971004 times.
✓ Branch 3 taken 70907 times.
✓ Branch 4 taken 172055 times.
✓ Branch 5 taken 60869856 times.
61504697 if(fading==fade_invisible || (((flags&guy_blinking)||(fading==fade_flicker)) && (clk&1)))
4002 634841 return true;
4003
4004
2/2
✓ Branch 0 taken 1371477 times.
✓ Branch 1 taken 59498379 times.
60869856 if(flags&guy_invisible)
4005 1371477 return true;
4006
4007
3/4
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 59497947 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 432 times.
59498379 if(flags&guy_lens_only && !lensclk)
4008 return true;
4009
4010 59498379 return false;
4011 61504697 }
4012
4013 #define DRAW_NORMAL 2
4014 #define DRAW_CLOAKED 1
4015 #define DRAW_INVIS 0
4016 // base drawing function to be used by all derived classes instead of
4017 // sprite::draw()
4018 44707983 void enemy::draw(BITMAP *dest)
4019 {
4020 44707983 didScriptThisFrame = false; //Since there's no better place to put it
4021
6/6
✓ Branch 0 taken 43944578 times.
✓ Branch 1 taken 763405 times.
✓ Branch 2 taken 43861928 times.
✓ Branch 3 taken 82650 times.
✓ Branch 4 taken 314578 times.
✓ Branch 5 taken 43630000 times.
44707983 if(fading==fade_invisible || (((flags&guy_blinking)||(fading==fade_flicker)) && (clk&1)))
4022 1077983 return;
4023
2/2
✓ Branch 0 taken 2767665 times.
✓ Branch 1 taken 40862335 times.
43630000 if(flags&guy_invisible)
4024 2767665 return;
4025
4026 //We did the normal don't_draw stuff here so we can make exceptions; specifically the lens check (which should make enemies
4027 // be cloaked if they have "invisible displays as cloaked" checked.
4028
4029 40862335 byte canSee = DRAW_NORMAL;
4030 //Enemy specific stuff
4031
2/2
✓ Branch 0 taken 40861171 times.
✓ Branch 1 taken 1164 times.
40862335 if ( editorflags & ENEMY_FLAG1 )
4032 {
4033 1164 canSee = DRAW_INVIS;
4034
1/2
✓ Branch 0 taken 1164 times.
✗ Branch 1 not taken.
1164 if (editorflags & ENEMY_FLAG4) canSee = DRAW_CLOAKED;
4035
2/4
✓ Branch 0 taken 1164 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1164 times.
✗ Branch 3 not taken.
1164 if (dmisc13 >= 0 && (editorflags & ENEMY_FLAG2))
4036 {
4037 if (game->item[dmisc13])
4038 {
4039 canSee = DRAW_NORMAL;
4040 }
4041 //else if ( lensclk && getlensid.flags SHOWINVIS )
4042 //{
4043 //
4044 //}
4045 //else
4046 //{
4047 // if ( (editorflags & ENEMY_FLAG4) ) canSee = DRAW_CLOAKED;
4048 // //otherwisem invisible
4049 //}
4050 }
4051 1164 }
4052 //Room specific
4053
2/2
✓ Branch 0 taken 38691136 times.
✓ Branch 1 taken 2171199 times.
40862335 if (tmpscr->flags3&fINVISROOM)
4054 {
4055
4/6
✓ Branch 0 taken 2171199 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 226004 times.
✓ Branch 3 taken 1945195 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 226004 times.
2397203 if (canSee == DRAW_NORMAL && !(current_item(itype_amulet)) &&
4056
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 226004 times.
226004 !((itemsbuf[Hero.getLastLensID()].flags & item_flag5) && lensclk) && family!=eeGANON) canSee = DRAW_CLOAKED;
4057 2171199 }
4058 //Lens check
4059
2/2
✓ Branch 0 taken 27345 times.
✓ Branch 1 taken 40834990 times.
40862335 if (lensclk)
4060 {
4061
2/2
✓ Branch 0 taken 26913 times.
✓ Branch 1 taken 432 times.
27345 if(flags&guy_lens_only)
4062 {
4063
1/2
✓ Branch 0 taken 432 times.
✗ Branch 1 not taken.
432 if (canSee == DRAW_INVIS) canSee = DRAW_NORMAL;
4064 432 }
4065 27345 }
4066 else
4067 {
4068
2/2
✓ Branch 0 taken 40761574 times.
✓ Branch 1 taken 73416 times.
40834990 if(flags&guy_lens_only)
4069 73416 canSee = DRAW_INVIS;
4070 }
4071
3/4
✓ Branch 0 taken 74580 times.
✓ Branch 1 taken 40787755 times.
✓ Branch 2 taken 74580 times.
✗ Branch 3 not taken.
40862335 if (canSee == DRAW_INVIS && (editorflags & ENEMY_FLAG4)) canSee = DRAW_CLOAKED;
4072
3/4
✓ Branch 0 taken 40561751 times.
✓ Branch 1 taken 300584 times.
✓ Branch 2 taken 40561751 times.
✗ Branch 3 not taken.
40862335 if (canSee == DRAW_NORMAL && (editorflags & ENEMY_FLAG16)) canSee = DRAW_CLOAKED;
4073
4074
2/2
✓ Branch 0 taken 40787755 times.
✓ Branch 1 taken 74580 times.
40862335 if (canSee == DRAW_INVIS)
4075 74580 return;
4076
4077
4/4
✓ Branch 0 taken 40785449 times.
✓ Branch 1 taken 2306 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 40785442 times.
40787755 if(fallclk||drownclk)
4078 {
4079
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2313 times.
2313 if (canSee == DRAW_CLOAKED)
4080 {
4081 sprite::drawcloaked(dest);
4082 }
4083
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2313 times.
2313 else if (canSee == DRAW_NORMAL)
4084 {
4085 2313 sprite::draw(dest);
4086 2313 }
4087 2313 return;
4088 }
4089 40785442 int32_t cshold=cs;
4090
4091
2/2
✓ Branch 0 taken 901813 times.
✓ Branch 1 taken 39883629 times.
40785442 if(dying)
4092 {
4093
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 901813 times.
901813 if(clk2>=19)
4094 {
4095 if(!(clk2&2))
4096 {
4097 //if the enemy isn't totally invisible, or if it is, but Hero has the item needed to reveal it, draw it.
4098 if (canSee == DRAW_CLOAKED)
4099 {
4100 sprite::drawcloaked(dest);
4101 }
4102 else if (canSee == DRAW_NORMAL)
4103 {
4104 sprite::draw(dest);
4105 }
4106 }
4107 return;
4108 }
4109
4110 901813 flip = 0;
4111 901813 tile = wpnsbuf[spr_death].tile;
4112
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 901813 times.
901813 if ( do_animation )
4113 {
4114 901813 int32_t offs = 0;
4115
2/2
✓ Branch 0 taken 850946 times.
✓ Branch 1 taken 50867 times.
901813 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS))
4116 {
4117
2/2
✓ Branch 0 taken 49251 times.
✓ Branch 1 taken 1616 times.
50867 if(clk2 > 2)
4118 {
4119 1616 spr_death_anim_clk=0;
4120 1616 clk2=1;
4121
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 1602 times.
1616 if(hp > -1000)
4122 1602 death_sfx();
4123 1616 }
4124
4/4
✓ Branch 0 taken 38168 times.
✓ Branch 1 taken 12699 times.
✓ Branch 2 taken 402 times.
✓ Branch 3 taken 37766 times.
50867 if(clk2==1 && spr_death_anim_clk>-1)
4125 {
4126 37766 ++clk2;
4127
2/2
✓ Branch 0 taken 2382 times.
✓ Branch 1 taken 35384 times.
37766 spr_death_anim_frm=(spr_death_anim_clk/zc_max(wpnsbuf[spr_death].speed,1));
4128
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 37745 times.
37766 spr_death_anim_frm *= zc_max(1,txsz);
4129 37766 int32_t rows = TILEROW(tile+spr_death_anim_frm)-TILEROW(tile);
4130
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 37690 times.
37766 spr_death_anim_frm += TILES_PER_ROW*(zc_min(0,tysz-1)*rows);
4131
6/6
✓ Branch 0 taken 2382 times.
✓ Branch 1 taken 35384 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 37764 times.
✓ Branch 4 taken 36168 times.
✓ Branch 5 taken 1598 times.
37766 if(++spr_death_anim_clk >= (zc_max(wpnsbuf[spr_death].speed,1) * zc_max(wpnsbuf[spr_death].frames,1)))
4132 {
4133 1598 spr_death_anim_clk=-1;
4134 1598 clk2=1;
4135 1598 }
4136 37766 }
4137 50867 tile += spr_death_anim_frm;
4138 50867 }
4139
2/2
✓ Branch 0 taken 313513 times.
✓ Branch 1 taken 537433 times.
850946 else if(BSZ)
4140 {
4141
2/2
✓ Branch 0 taken 246522 times.
✓ Branch 1 taken 66991 times.
313513 offs = zc_min((15-clk2)/3,4);
4142 313513 }
4143
4/4
✓ Branch 0 taken 358367 times.
✓ Branch 1 taken 179066 times.
✓ Branch 2 taken 179055 times.
✓ Branch 3 taken 179312 times.
537433 else if(clk2>6 && clk2<=12)
4144 {
4145 179312 offs = 1;
4146 179312 }
4147
4148
2/2
✓ Branch 0 taken 455138 times.
✓ Branch 1 taken 446675 times.
901813 if(offs)
4149 {
4150
2/2
✓ Branch 0 taken 450 times.
✓ Branch 1 taken 446225 times.
446675 offs *= zc_max(1,txsz);
4151 446675 int32_t rows = TILEROW(tile+offs)-TILEROW(tile);
4152
2/2
✓ Branch 0 taken 438 times.
✓ Branch 1 taken 446237 times.
446675 offs += TILES_PER_ROW*(zc_min(0,tysz-1)*rows);
4153 446675 }
4154 901813 tile += offs;
4155 901813 }
4156
4157
6/6
✓ Branch 0 taken 850946 times.
✓ Branch 1 taken 50867 times.
✓ Branch 2 taken 537433 times.
✓ Branch 3 taken 313513 times.
✓ Branch 4 taken 189182 times.
✓ Branch 5 taken 348251 times.
901813 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS) || BSZ || fading==fade_blue_poof)
4158 553562 cs = wpnsbuf[spr_death].csets&15;
4159 else
4160 348251 cs = (((clk2+5)>>1)&3)+6;
4161 901813 }
4162
3/4
✓ Branch 0 taken 1189644 times.
✓ Branch 1 taken 38693985 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1189644 times.
39883629 else if(hclk>0 && getCanFlicker())
4163 {
4164 1189644 cs = getFlashingCSet();
4165 1189644 }
4166 //draw every other frame for flickering enemies
4167
2/2
✓ Branch 0 taken 248031 times.
✓ Branch 1 taken 40537411 times.
40785442 if (is_hitflickerframe(false))
4168 {
4169
5/6
✓ Branch 0 taken 90246 times.
✓ Branch 1 taken 157785 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 90245 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 157786 times.
248031 int32_t temp_flicker_color = (hp > 0 || immortal) ? (flickercolor < 0 ? game->get_spriteflickercolor() : flickercolor) : 0;
4170
2/4
✓ Branch 0 taken 248031 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 248031 times.
248031 if (game->get_spriteflickercolor() || temp_flicker_color)
4171 {
4172 sprite_flicker_transp_passes = (flickertransp < 0 ? game->get_spriteflickertransp() : flickertransp);
4173 sprite_flicker_color = temp_flicker_color;
4174 sprite::draw(dest);
4175 }
4176 248031 }
4177 else
4178 {
4179
2/2
✓ Branch 0 taken 225162 times.
✓ Branch 1 taken 40312249 times.
40537411 if (canSee == DRAW_CLOAKED)
4180 {
4181 225162 sprite::drawcloaked(dest);
4182 225162 }
4183
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40312249 times.
40312249 else if (canSee == DRAW_NORMAL)
4184 {
4185
1/2
✓ Branch 0 taken 40312249 times.
✗ Branch 1 not taken.
40312249 if ( frozenclock < 0 )
4186 {
4187 if ( frozentile > 0 ) tile = frozentile;
4188 loadpalset(csBOSS,frozencset);
4189 }
4190 40312249 sprite::draw(dest);
4191 40312249 }
4192 }
4193 40785442 cs=cshold;
4194 44707983 }
4195
4196 //old zc bosses
4197 40756307 void enemy::drawzcboss(BITMAP *dest)
4198 {
4199 40756307 didScriptThisFrame = false; //Since there's no better place to put it
4200
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40756307 times.
40756307 if(dont_draw())
4201 return;
4202
4203 40756307 int32_t cshold=cs;
4204
4205
2/2
✓ Branch 0 taken 781872 times.
✓ Branch 1 taken 39974435 times.
40756307 if(dying)
4206 {
4207
2/2
✓ Branch 0 taken 3960 times.
✓ Branch 1 taken 777912 times.
781872 if(clk2>=19)
4208 {
4209
2/2
✓ Branch 0 taken 1980 times.
✓ Branch 1 taken 1980 times.
3960 if(!(clk2&2))
4210 1980 sprite::drawzcboss(dest);
4211
4212 3960 return;
4213 }
4214
4215 777912 flip = 0;
4216 777912 tile = wpnsbuf[spr_death].tile;
4217
4218
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 777912 times.
777912 if ( do_animation )
4219 {
4220
2/2
✓ Branch 0 taken 773396 times.
✓ Branch 1 taken 4516 times.
777912 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS))
4221 {
4222
2/2
✓ Branch 0 taken 4510 times.
✓ Branch 1 taken 6 times.
4516 if(clk2 > 2)
4223 {
4224 6 spr_death_anim_clk=0;
4225 6 clk2=1;
4226
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(hp > -1000)
4227 6 death_sfx();
4228 6 }
4229
4/4
✓ Branch 0 taken 260 times.
✓ Branch 1 taken 4256 times.
✓ Branch 2 taken 184 times.
✓ Branch 3 taken 76 times.
4516 if(clk2==1 && spr_death_anim_clk>-1)
4230 {
4231 76 ++clk2;
4232
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 spr_death_anim_frm=(spr_death_anim_clk/zc_max(wpnsbuf[spr_death].speed,1));
4233
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 spr_death_anim_frm *= zc_max(1,txsz);
4234 76 int32_t rows = TILEROW(tile+spr_death_anim_frm)-TILEROW(tile);
4235
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 spr_death_anim_frm += TILES_PER_ROW*(zc_min(0,tysz-1)*rows);
4236
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 76 times.
✓ Branch 4 taken 74 times.
✓ Branch 5 taken 2 times.
76 if(++spr_death_anim_clk >= (zc_max(wpnsbuf[spr_death].speed,1) * zc_max(wpnsbuf[spr_death].frames,1)))
4237 {
4238 2 spr_death_anim_clk=-1;
4239 2 clk2=1;
4240 2 }
4241 76 }
4242 4516 tile += spr_death_anim_frm;
4243 4516 }
4244
2/2
✓ Branch 0 taken 276492 times.
✓ Branch 1 taken 496904 times.
773396 else if(BSZ)
4245
2/2
✓ Branch 0 taken 217484 times.
✓ Branch 1 taken 59008 times.
276492 tile += zc_min((15-clk2)/3,4);
4246
4/4
✓ Branch 0 taken 331233 times.
✓ Branch 1 taken 165671 times.
✓ Branch 2 taken 165514 times.
✓ Branch 3 taken 165719 times.
496904 else if(clk2>6 && clk2<=12)
4247 165719 ++tile;
4248 777912 }
4249
4250
6/6
✓ Branch 0 taken 773396 times.
✓ Branch 1 taken 4516 times.
✓ Branch 2 taken 496904 times.
✓ Branch 3 taken 276492 times.
✓ Branch 4 taken 183872 times.
✓ Branch 5 taken 313032 times.
777912 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS) || BSZ || fading==fade_blue_poof)
4251 464880 cs = wpnsbuf[spr_death].csets&15;
4252 else
4253 313032 cs = (((clk2+5)>>1)&3)+6;
4254 777912 }
4255
2/2
✓ Branch 0 taken 38774165 times.
✓ Branch 1 taken 1200270 times.
39974435 else if(hclk>0)
4256 {
4257 1200270 cs = getFlashingCSet();
4258 1200270 }
4259
4260
3/4
✓ Branch 0 taken 2045619 times.
✓ Branch 1 taken 38706728 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7543 times.
40759890 if((tmpscr->flags3&fINVISROOM) &&
4261
2/2
✓ Branch 0 taken 7543 times.
✓ Branch 1 taken 2038076 times.
2045619 !(current_item(itype_amulet)) &&
4262
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7543 times.
7543 !(get_qr(qr_LENSSEESENEMIES) &&
4263 7543 lensclk) && family!=eeGANON)
4264 {
4265 7543 sprite::drawcloaked(dest);
4266 7543 }
4267 else
4268 {
4269
2/2
✓ Branch 0 taken 23473 times.
✓ Branch 1 taken 40721331 times.
40744804 if (is_hitflickerframe(true))
4270 {
4271
4/6
✓ Branch 0 taken 885 times.
✓ Branch 1 taken 22588 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 885 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 22588 times.
23473 int32_t temp_flicker_color = (hp > 0 || immortal) ? (flickercolor < 0 ? game->get_spriteflickercolor() : flickercolor) : 0;
4272
1/2
✓ Branch 0 taken 23473 times.
✗ Branch 1 not taken.
23473 if (game->get_spriteflickercolor())
4273 {
4274 sprite_flicker_transp_passes = (flickertransp < 0 ? game->get_spriteflickertransp() : flickertransp);
4275 sprite_flicker_color = temp_flicker_color;
4276 sprite::drawzcboss(dest);
4277 }
4278 23473 }
4279 else
4280 40721331 sprite::drawzcboss(dest);
4281 }
4282
4283 40752347 cs=cshold;
4284 40756307 }
4285
4286
4287 // similar to the overblock function--can do up to a 32x32 sprite
4288 //will this play nicely with scripttile, solely using the modifications in sprite::draw()?
4289 323235 void enemy::drawblock(BITMAP *dest,int32_t mask)
4290 {
4291 323235 int32_t thold=tile;
4292 323235 int32_t t1=tile;
4293 323235 int32_t t2=tile+20;
4294 323235 int32_t t3=tile+1;
4295 323235 int32_t t4=tile+21;
4296
4297
1/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 323235 times.
323235 switch(mask)
4298 {
4299 case 1:
4300 enemy::drawzcboss(dest);
4301 break;
4302
4303 case 3:
4304 if(flip&2)
4305 zc_swap(t1,t2);
4306
4307 tile=t1;
4308 enemy::drawzcboss(dest);
4309 tile=t2;
4310 yofs+=16;
4311 enemy::drawzcboss(dest);
4312 yofs-=16;
4313 break;
4314
4315 case 5:
4316 t2=tile+1;
4317
4318 if(flip&1)
4319 zc_swap(t1,t2);
4320
4321 tile=t1;
4322 enemy::drawzcboss(dest);
4323 tile=t2;
4324 xofs+=16;
4325 enemy::drawzcboss(dest);
4326 xofs-=16;
4327 break;
4328
4329 case 15:
4330
2/2
✓ Branch 0 taken 316479 times.
✓ Branch 1 taken 6756 times.
323235 if(flip&1)
4331 {
4332 6756 zc_swap(t1,t3);
4333 6756 zc_swap(t2,t4);
4334 6756 }
4335
4336
1/2
✓ Branch 0 taken 323235 times.
✗ Branch 1 not taken.
323235 if(flip&2)
4337 {
4338 zc_swap(t1,t2);
4339 zc_swap(t3,t4);
4340 }
4341
4342 323235 tile=t1;
4343 323235 enemy::drawzcboss(dest);
4344 323235 tile=t2;
4345 323235 yofs+=16;
4346 323235 enemy::drawzcboss(dest);
4347 323235 yofs-=16;
4348 323235 tile=t3;
4349 323235 xofs+=16;
4350 323235 enemy::drawzcboss(dest);
4351 323235 tile=t4;
4352 323235 yofs+=16;
4353 323235 enemy::drawzcboss(dest);
4354 323235 xofs-=16;
4355 323235 yofs-=16;
4356 323235 break;
4357 }
4358
4359 323235 tile=thold;
4360 323235 }
4361
4362 20184565 void enemy::drawshadow(BITMAP *dest, bool translucent)
4363 {
4364
4/4
✓ Branch 0 taken 18178247 times.
✓ Branch 1 taken 2006318 times.
✓ Branch 2 taken 406089 times.
✓ Branch 3 taken 17772158 times.
20184565 if(dont_draw() || isSideViewGravity())
4365 {
4366 2412407 return;
4367 }
4368
4369
2/2
✓ Branch 0 taken 327154 times.
✓ Branch 1 taken 17445004 times.
17772158 if(dying)
4370 {
4371 327154 return;
4372 }
4373
4374
4/4
✓ Branch 0 taken 1718249 times.
✓ Branch 1 taken 15726755 times.
✓ Branch 2 taken 347010 times.
✓ Branch 3 taken 17097994 times.
17445004 if(((tmpscr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))||
4375 17445004 (darkroom))
4376 {
4377 347010 return;
4378 }
4379 else
4380 {
4381
4/4
✓ Branch 0 taken 16521565 times.
✓ Branch 1 taken 576429 times.
✓ Branch 2 taken 16474191 times.
✓ Branch 3 taken 47374 times.
17097994 if(enemycanfall(id, false) && shadowtile == 0)
4382 47374 shadowtile = wpnsbuf[spr_shadow].tile;
4383
4384
5/6
✓ Branch 0 taken 16159630 times.
✓ Branch 1 taken 938364 times.
✓ Branch 2 taken 16159630 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15583201 times.
✓ Branch 5 taken 576429 times.
17097994 if(z>0 || fakez>0 || !enemycanfall(id, false))
4385 {
4386
2/2
✓ Branch 0 taken 275 times.
✓ Branch 1 taken 1514518 times.
1514793 if(!shadow_overpit(this))
4387 1514518 sprite::drawshadow(dest,translucent);
4388 1514793 }
4389 }
4390 20184565 }
4391
4392 129181 void enemy::masked_draw(BITMAP *dest,int32_t mx,int32_t my,int32_t mw,int32_t mh)
4393 {
4394 129181 BITMAP *sub=create_sub_bitmap(dest,mx,my,mw,mh);
4395
4396
1/2
✓ Branch 0 taken 129181 times.
✗ Branch 1 not taken.
129181 if(sub!=NULL)
4397 {
4398 129181 xofs-=mx;
4399 129181 yofs-=my;
4400 129181 enemy::draw(sub);
4401 129181 xofs+=mx;
4402 129181 yofs+=my;
4403 129181 destroy_bitmap(sub);
4404 129181 }
4405 else
4406 enemy::draw(dest);
4407 129181 }
4408
4409 9 void enemy::init_size_flags()
4410 {
4411
3/6
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 9 times.
9 if (((SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; }
4412
3/6
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 9 times.
9 if (((SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
4413
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
9 if (((SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0) hit_width = d->hxsz;
4414
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
9 if (((SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0) hit_height = d->hysz;
4415
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9 if (((SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0) hzsz = d->hzsz;
4416
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ((SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
4417
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ((SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
4418
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ((SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)d->xofs;
4419
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ((SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
4420 {
4421 yofs = (int32_t)d->yofs;
4422 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset);
4423 }
4424
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ((SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)d->zofs;
4425 9 }
4426
4427 // override hit detection to check for invicibility, stunned, etc
4428 112163784 bool enemy::hit()
4429 {
4430
4/4
✓ Branch 0 taken 110840424 times.
✓ Branch 1 taken 1323360 times.
✓ Branch 2 taken 109045288 times.
✓ Branch 3 taken 1795136 times.
112163784 if(dying || hclk>0) return false;
4431 109045288 return sprite::hit();
4432 112163784 }
4433 730351 bool enemy::hit(sprite *s)
4434 {
4435
3/4
✓ Branch 0 taken 730351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 713374 times.
✓ Branch 3 taken 16977 times.
730351 if(!hit() || !s->hit()) return false;
4436 713374 return sprite::hit(s);
4437 730351 }
4438
4439 44504122 bool enemy::hit(int32_t tx,int32_t ty,int32_t tz,int32_t txsz2,int32_t tysz2,int32_t tzsz2)
4440 {
4441
2/2
✓ Branch 0 taken 3919460 times.
✓ Branch 1 taken 40584662 times.
44504122 if(!hit()) return false;
4442 40584662 return sprite::hit(tx,ty,tz,txsz2,tysz2,tzsz2);
4443 44504122 }
4444 78011 bool enemy::hit(int32_t tx,int32_t ty,int32_t txsz2,int32_t tysz2)
4445 {
4446
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 78011 times.
78011 if(!hit()) return false;
4447 78011 return sprite::hit(tx,ty,txsz2,tysz2);
4448 78011 }
4449
4450 11135644 bool enemy::hit(weapon *w)
4451 {
4452
2/2
✓ Branch 0 taken 1172782 times.
✓ Branch 1 taken 9962862 times.
11135644 if(!hit()) return false;
4453
4454
2/2
✓ Branch 0 taken 6645889 times.
✓ Branch 1 taken 3316973 times.
9962862 if (replay_version_check(0, 14))
4455 {
4456
4/6
✓ Branch 0 taken 6421582 times.
✓ Branch 1 taken 224307 times.
✓ Branch 2 taken 6421582 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6421582 times.
✗ Branch 5 not taken.
6645889 if(!w->scriptcoldet || w->fallclk || w->drownclk)
4457 224307 return false;
4458 6421582 return sprite::hit(w);
4459 }
4460 3316973 return w->hit(this);
4461 11135644 }
4462
4463 9459772 bool enemy::can_pitfall(bool checkspawning)
4464 {
4465
4/4
✓ Branch 0 taken 9439961 times.
✓ Branch 1 taken 19811 times.
✓ Branch 2 taken 9429306 times.
✓ Branch 3 taken 30466 times.
9459772 if((fading||isspawning)&&checkspawning) return false; //Don't fall during spawn.
4466
2/2
✓ Branch 0 taken 9411644 times.
✓ Branch 1 taken 17662 times.
9429306 switch(guysbuf[id&0xFFF].family)
4467 {
4468 case eeAQUA:
4469 case eeDIG:
4470 case eeDONGO:
4471 case eeFAIRY:
4472 case eeGANON:
4473 case eeGHOMA:
4474 case eeGLEEOK:
4475 case eeGUY:
4476 case eeLANM:
4477 case eeMANHAN:
4478 case eeMOLD:
4479 case eeNONE:
4480 case eePATRA:
4481 case eeZORA:
4482 17662 return false; //Disallowed types
4483 default:
4484 9411644 return true;
4485 }
4486 9459772 }
4487 //Handle death
4488 37829387 void enemy::try_death(bool force_kill)
4489 {
4490
8/8
✓ Branch 0 taken 37774144 times.
✓ Branch 1 taken 55243 times.
✓ Branch 2 taken 37774133 times.
✓ Branch 3 taken 11 times.
✓ Branch 4 taken 43509 times.
✓ Branch 5 taken 37730624 times.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 43508 times.
37829387 if(!dying && (force_kill || (hp<=0 && !immortal)))
4491 {
4492 43519 std::vector<int32_t> &ev = FFCore.eventData;
4493 43519 ev.clear();
4494 43519 ev.push_back(10000);
4495 43519 ev.push_back(getUID());
4496
4497 43519 throwGenScriptEvent(GENSCR_EVENT_ENEMY_DEATH);
4498 43519 bool isSaved = !ev[0];
4499 43519 ev.clear();
4500
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43519 times.
43519 if(isSaved) return;
4501
4502
4/4
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 43471 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 42 times.
43519 if(itemguy && (hasitem&2)!=0)
4503 {
4504
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 42 times.
89 for(int32_t i=0; i<items.Count(); i++)
4505 {
4506
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 42 times.
47 if(((item*)items.spr(i))->pickup&ipENEMY)
4507 {
4508
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 1 times.
42 if (!get_qr(qr_BROKEN_ITEM_CARRYING))
4509 {
4510
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (get_qr(qr_ENEMY_DROPS_USE_HITOFFSETS))
4511 {
4512 items.spr(i)->x = x+hxofs+(hit_width/2)-8;
4513 items.spr(i)->y = y+hyofs+(hit_height/2)-10-fakez;
4514 }
4515 else
4516 {
4517
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(extend >= 3)
4518 {
4519 items.spr(i)->x = x+(txsz-1)*8;
4520 items.spr(i)->y = y-2+(tysz-1)*8;
4521 }
4522 else
4523 {
4524 1 items.spr(i)->x = x;
4525 1 items.spr(i)->y = y - 2;
4526 }
4527 }
4528 1 items.spr(i)->z = z;
4529 1 items.spr(i)->fakez = fakez;
4530 1 }
4531 else
4532 {
4533 41 items.spr(i)->x = x;
4534 41 items.spr(i)->y = y - 2;
4535 }
4536 42 }
4537 47 }
4538 42 }
4539
4540 43519 dying=true;
4541
4542
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 43487 times.
43519 if(fading==fade_flash_die)
4543 32 clk2=19+18*4;
4544 else
4545 {
4546 43487 clk2 = BSZ ? 15 : 19;
4547
4548
2/2
✓ Branch 0 taken 21051 times.
✓ Branch 1 taken 22436 times.
43487 if(fading!=fade_blue_poof)
4549 22436 fading=0;
4550 }
4551
4552
2/2
✓ Branch 0 taken 43471 times.
✓ Branch 1 taken 48 times.
43519 if(itemguy)
4553 {
4554 48 hasitem&=~2;
4555 48 item_set=0;
4556 48 }
4557
4558
6/6
✓ Branch 0 taken 42465 times.
✓ Branch 1 taken 1054 times.
✓ Branch 2 taken 33780 times.
✓ Branch 3 taken 8685 times.
✓ Branch 4 taken 1428 times.
✓ Branch 5 taken 32352 times.
43519 if(currscr<128 && count_enemy && !script_spawned)
4559 32352 game->guys[(currmap<<7)+currscr]-=1;
4560 43519 }
4561 37829387 }
4562
4563 // --==**==--
4564
4565 // Movement routines that can be used by derived classes as needed
4566
4567 // --==**==--
4568
4569 555797 void enemy::fix_coords(bool bound)
4570 {
4571
1/2
✓ Branch 0 taken 555797 times.
✗ Branch 1 not taken.
555797 if ((get_qr(qr_OUTOFBOUNDSENEMIES) ? 1 : 0) ^ ((editorflags&ENEMY_FLAG11)?1:0)) return;
4572
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 555797 times.
555797 if(moveflags & move_ignore_screenedge) bound = false;
4573
4574
4575
2/2
✓ Branch 0 taken 81680 times.
✓ Branch 1 taken 474117 times.
555797 if(bound)
4576 {
4577
1/2
✓ Branch 0 taken 474117 times.
✗ Branch 1 not taken.
474117 if ( ((unsigned)(id&0xFFF)) < MAXGUYS )
4578 {
4579
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 474115 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
474117 x=vbound(x, 0_zf, (( guysbuf[id].SIZEflags&OVERRIDE_TILE_WIDTH && !isflier(id) ) ? (256_zf -((txsz-1)*16)) : 240_zf));
4580
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 474115 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
474117 y=vbound(y, 0_zf,(( guysbuf[id].SIZEflags&OVERRIDE_TILE_HEIGHT && !isflier(id) ) ? (176_zf -((txsz-1)*16)) : 160_zf));
4581 474117 }
4582 else
4583 {
4584 x=vbound(x, 0_zf,240_zf);
4585 y=vbound(y, 0_zf,160_zf);
4586 }
4587 474117 }
4588
4589
6/10
✓ Branch 0 taken 554783 times.
✓ Branch 1 taken 1014 times.
✓ Branch 2 taken 555797 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 555797 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 555797 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 555797 times.
555797 if(!OUTOFBOUNDS)
4590 {
4591 /*x=((int32_t(x)&0xF0)+((int32_t(x)&8)?16:0));
4592
4593 if(isSideViewGravity())
4594 y=((int32_t(y)&0xF8)+((int32_t(y)&4)?8:0));
4595 else
4596 y=((int32_t(y)&0xF0)+((int32_t(y)&8)?16:0));
4597 */
4598 555797 do_fix(x, 16, true);
4599
2/2
✓ Branch 0 taken 1014 times.
✓ Branch 1 taken 554783 times.
555797 if(isSideViewGravity())
4600 1014 do_fix(y,8,true);
4601 554783 else do_fix(y,16,true);
4602 555797 }
4603 555797 }
4604 9156 bool enemy::cannotpenetrate()
4605 {
4606
4/4
✓ Branch 0 taken 8975 times.
✓ Branch 1 taken 181 times.
✓ Branch 2 taken 38 times.
✓ Branch 3 taken 8937 times.
9156 return (family == eeAQUA || family == eeMANHAN || family == eeGHOMA);
4607 }
4608
4609 562 bool enemy::canmove_old(int32_t ndir,zfix s,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
4610 {
4611 bool ok;
4612 562 int32_t dx = 0, dy = 0;
4613 562 int32_t sv = 8;
4614
4615 //Why is this here??? Why is it needed???
4616 562 s += 0.5; // Make the ints round; doesn't seem to cause any problems.
4617
4618
8/9
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 51 times.
✓ Branch 2 taken 47 times.
✓ Branch 3 taken 85 times.
✓ Branch 4 taken 94 times.
✓ Branch 5 taken 78 times.
✓ Branch 6 taken 57 times.
✓ Branch 7 taken 81 times.
✗ Branch 8 not taken.
562 switch(ndir)
4619 {
4620 case 8:
4621 case up:
4622
3/4
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 31 times.
✓ Branch 2 taken 38 times.
✗ Branch 3 not taken.
69 if(canfall(id) && isSideViewGravity())
4623 return false;
4624
4625 69 dy = dy1-s;
4626
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 69 times.
69 special = (special==spw_clipbottomright)?spw_none:special;
4627
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 69 times.
69 ok = !m_walkflag_old(x,y+dy,special, x, y) && !flyerblocked(x,y+dy, special);
4628 69 break;
4629
4630 case 12:
4631 case down:
4632
3/4
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 20 times.
✓ Branch 2 taken 31 times.
✗ Branch 3 not taken.
51 if(canfall(id) && isSideViewGravity())
4633 return false;
4634
4635 51 dy = dy2+s;
4636
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51 times.
51 ok = !m_walkflag_old(x,y+dy,special, x, y) && !flyerblocked(x,y+dy, special);
4637 51 break;
4638
4639 case 14:
4640 case left:
4641 47 dx = dx1-s;
4642 47 sv = ((isSideViewGravity())?7:8);
4643
2/4
✓ Branch 0 taken 47 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 47 times.
47 special = (special==spw_clipbottomright||special==spw_clipright)?spw_none:special;
4644
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 45 times.
47 ok = !m_walkflag_old(x+dx,y+sv,special, x, y) && !flyerblocked(x+dx,y+8, special);
4645 47 break;
4646
4647 case 10:
4648 case right:
4649 85 dx = dx2+s;
4650 85 sv = ((isSideViewGravity())?7:8);
4651
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 79 times.
85 ok = !m_walkflag_old(x+dx,y+sv,special, x, y) && !flyerblocked(x+dx,y+8, special);
4652 85 break;
4653
4654 case 9:
4655 case r_up:
4656 94 dx = dx2+s;
4657 94 dy = dy1-s;
4658
3/4
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 93 times.
✓ Branch 3 taken 1 times.
187 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4659
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
93 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4660 94 break;
4661
4662 case 11:
4663 case r_down:
4664 78 dx = dx2+s;
4665 78 dx = dy2+s;
4666
3/4
✓ Branch 0 taken 78 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 1 times.
155 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4667
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4668 78 break;
4669
4670 case 13:
4671 case l_down:
4672 57 dx = dx1-s;
4673 57 dy = dy2+s;
4674
3/4
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 55 times.
✗ Branch 3 not taken.
112 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4675
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
55 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4676 57 break;
4677
4678 case 15:
4679 case l_up:
4680 81 dx = dx1-s;
4681 81 dy = dy1-s;
4682
3/4
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 80 times.
✓ Branch 3 taken 1 times.
161 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4683
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
80 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4684 81 break;
4685
4686 default:
4687 db=99;
4688 return true;
4689 }
4690
4691 562 return ok;
4692 562 }
4693
4694
4695
4696
4697 // returns true if next step is ok, false if there is something there
4698 7325205 bool enemy::canmove(int32_t ndir,zfix s,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2, bool kb)
4699 {
4700 7325205 bool ok = false; //initialise the var, son't just declare it
4701 7325205 int32_t dx = 0, dy = 0;
4702 7325205 int32_t sv = 8;
4703 7325205 int32_t tries = 2; int32_t try_x = 0; int32_t try_y = 0;
4704 //Why is this here??? Why is it needed???
4705 7325205 s += 0.5; // Make the ints round; doesn't seem to cause any problems.
4706
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7325205 times.
7325205 int32_t usexoffs = (SIZEflags&OVERRIDE_HIT_X_OFFSET) ? hxofs : 0;
4707
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7325205 times.
7325205 int32_t useyoffs = (SIZEflags&OVERRIDE_HIT_Y_OFFSET) ? hyofs : 0;
4708
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 7325192 times.
7325205 int32_t usewid = (SIZEflags&OVERRIDE_HIT_WIDTH) ? hit_width : 16;
4709
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 7325192 times.
7325205 int32_t usehei = (SIZEflags&OVERRIDE_HIT_HEIGHT) ? hit_height : 16;
4710 7325205 bool offgrid = OFFGRID_ENEMY;
4711
2/2
✓ Branch 0 taken 7291 times.
✓ Branch 1 taken 7317914 times.
7325205 if(!offgrid)
4712 {
4713 //Enemies smaller than 1-tile must act as 1-tile large, if off-grid movement is disabled.
4714
1/2
✓ Branch 0 taken 7317914 times.
✗ Branch 1 not taken.
7317914 if(usehei<16)usehei=16;
4715
1/2
✓ Branch 0 taken 7317914 times.
✗ Branch 1 not taken.
7317914 if(usewid<16)usewid=16;
4716 7317914 }
4717
9/9
✓ Branch 0 taken 1327873 times.
✓ Branch 1 taken 1102923 times.
✓ Branch 2 taken 1221995 times.
✓ Branch 3 taken 1212911 times.
✓ Branch 4 taken 536645 times.
✓ Branch 5 taken 638123 times.
✓ Branch 6 taken 600184 times.
✓ Branch 7 taken 564898 times.
✓ Branch 8 taken 119653 times.
7325205 switch(ndir) //need to check every 8 pixels between two points
4718 {
4719 case 8:
4720 case up:
4721 {
4722
4/4
✓ Branch 0 taken 150619 times.
✓ Branch 1 taken 1177254 times.
✓ Branch 2 taken 150029 times.
✓ Branch 3 taken 590 times.
1327873 if(enemycanfall(id) && isSideViewGravity())
4723 590 return false;
4724
4725 1327283 dy = dy1-s;
4726
2/2
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 1326803 times.
1327283 special = (special==spw_clipbottomright)?spw_none:special;
4727 1327283 tries = usewid/(offgrid ? 8 : 16);
4728 //Z_eventlog("Trying move UP, dy=%d,usewid=%d,usehei=%d\n",int32_t(dy),usewid,usehei);
4729
2/2
✓ Branch 0 taken 1127175 times.
✓ Branch 1 taken 1327933 times.
2455108 for ( ; tries > 0; --tries )
4730 {
4731
2/2
✓ Branch 0 taken 197488 times.
✓ Branch 1 taken 1130445 times.
1327933 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy,special, ndir, x+usexoffs+try_x, y+useyoffs, kb) && !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy, special,kb);
4732 1327933 try_x += (offgrid ? 8 : 16);
4733
2/2
✓ Branch 0 taken 1127825 times.
✓ Branch 1 taken 200108 times.
1327933 if (!ok) break;
4734 1127825 }
4735
2/2
✓ Branch 0 taken 1127175 times.
✓ Branch 1 taken 200108 times.
1327283 if(!ok) break;
4736
1/2
✓ Branch 0 taken 1127175 times.
✗ Branch 1 not taken.
1127175 if((usewid%16)>0) //Uneven width
4737 {
4738 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy,special, ndir, x+usexoffs+usewid-1, y+useyoffs, kb) && !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy, special,kb);
4739 }
4740 1127175 break;
4741 }
4742 case 12:
4743 case down:
4744 {
4745
4/4
✓ Branch 0 taken 180553 times.
✓ Branch 1 taken 922370 times.
✓ Branch 2 taken 179865 times.
✓ Branch 3 taken 688 times.
1102923 if(enemycanfall(id) && isSideViewGravity())
4746 688 return false;
4747
4748 1102235 dy = dy2+s;
4749 1102235 tries = usewid/(offgrid ? 8 : 16);
4750 //Z_eventlog("Trying move DOWN, dy=%d,usewid=%d,usehei=%d\n",int32_t(dy),usewid,usehei);
4751
2/2
✓ Branch 0 taken 896244 times.
✓ Branch 1 taken 1103019 times.
1999263 for ( ; tries > 0; --tries )
4752 {
4753
3/4
✓ Branch 0 taken 205243 times.
✓ Branch 1 taken 897776 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 897776 times.
1103019 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy,special, ndir, x+usexoffs+try_x, y+useyoffs, kb) && !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+zc_max(usehei-16,0), special,kb);
4754 1103019 try_x += (offgrid ? 8 : 16);
4755
2/2
✓ Branch 0 taken 897028 times.
✓ Branch 1 taken 205991 times.
1103019 if (!ok) break;
4756 897028 }
4757
2/2
✓ Branch 0 taken 896244 times.
✓ Branch 1 taken 205991 times.
1102235 if(!ok) break;
4758
1/2
✓ Branch 0 taken 896244 times.
✗ Branch 1 not taken.
896244 if((usewid%16)>0) //Uneven width
4759 {
4760 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy,special, ndir, x+usexoffs+usewid-1, y+useyoffs, kb) && !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+zc_max(usehei-16,0), special,kb);
4761 }
4762 896244 break;
4763 }
4764 case 14:
4765 case left:
4766 {
4767 1221995 dx = dx1-s;
4768 1221995 sv = ((isSideViewGravity())?7:0);
4769
4/4
✓ Branch 0 taken 1221372 times.
✓ Branch 1 taken 623 times.
✓ Branch 2 taken 1768 times.
✓ Branch 3 taken 1219604 times.
1221995 special = (special==spw_clipbottomright||special==spw_clipright)?spw_none:special;
4770 1221995 tries = usehei/(offgrid ? 8 : 16);
4771 //Z_eventlog("Trying move LEFT, dx=%d,usewid=%d,usehei=%d\n",int32_t(dx),usewid,usehei);
4772
2/2
✓ Branch 0 taken 1023070 times.
✓ Branch 1 taken 1222912 times.
2245982 for ( ; tries > 0; --tries )
4773 {
4774
2/2
✓ Branch 0 taken 197742 times.
✓ Branch 1 taken 1025170 times.
1222912 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+try_y+sv,special, ndir, x+usexoffs, y+useyoffs+try_y, kb) && !flyerblocked(x+usexoffs+dx,y+8+useyoffs+try_y, special,kb);
4775 1222912 try_y += (offgrid ? 8 : 16);
4776
2/2
✓ Branch 0 taken 1023987 times.
✓ Branch 1 taken 198925 times.
1222912 if (!ok) break;
4777 1023987 }
4778
2/2
✓ Branch 0 taken 1023070 times.
✓ Branch 1 taken 198925 times.
1221995 if(!ok) break;
4779
1/2
✓ Branch 0 taken 1023070 times.
✗ Branch 1 not taken.
1023070 if((usehei%16)>0) //Uneven height
4780 {
4781 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+usehei-1+sv,special, ndir, x+usexoffs, y+useyoffs+usehei-1, kb) && !flyerblocked(x+usexoffs+dx,y+8+useyoffs+usehei-1, special,kb);
4782 }
4783 1023070 break;
4784 }
4785 case 10:
4786 case right:
4787 {
4788 1212911 dx = dx2+s;
4789 1212911 sv = ((isSideViewGravity())?7:0);
4790 1212911 tries = usehei/(offgrid ? 8 : 16);
4791 //Z_eventlog("Trying move RIGHT, dx=%d,usewid=%d,usehei=%d\n",int32_t(dx),usewid,usehei);
4792
2/2
✓ Branch 0 taken 1024814 times.
✓ Branch 1 taken 1213805 times.
2238619 for ( ; tries > 0; --tries )
4793 {
4794
3/4
✓ Branch 0 taken 186744 times.
✓ Branch 1 taken 1027061 times.
✓ Branch 2 taken 1027061 times.
✗ Branch 3 not taken.
1213805 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+try_y+sv,special, ndir, x+usexoffs, y+useyoffs+try_y, kb) && !flyerblocked(x+usexoffs+dx+zc_max(usewid-16,0),y+8+useyoffs+try_y, special,kb);
4795 1213805 try_y += (offgrid ? 8 : 16);
4796
2/2
✓ Branch 0 taken 1025708 times.
✓ Branch 1 taken 188097 times.
1213805 if (!ok) break;
4797 1025708 }
4798
2/2
✓ Branch 0 taken 1024814 times.
✓ Branch 1 taken 188097 times.
1212911 if(!ok) break;
4799
1/2
✓ Branch 0 taken 1024814 times.
✗ Branch 1 not taken.
1024814 if((usehei%16)>0) //Uneven height
4800 {
4801 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+usehei-1+sv,special, ndir, x+usexoffs, y+useyoffs+usehei-1, kb) && !flyerblocked(x+usexoffs+dx+zc_max(usewid-16,0),y+8+useyoffs+usehei-1, special,kb);
4802 }
4803 1024814 break;
4804 }
4805 case 9:
4806 case r_up:
4807 {
4808 536645 dx = dx2+s;
4809 536645 dy = dy1-s;
4810 536645 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4811 536645 sv = ((isSideViewGravity())?7:0);
4812
2/2
✓ Branch 0 taken 519643 times.
✓ Branch 1 taken 536645 times.
1056288 for ( ; tries_x > 0; --tries_x )
4813 {
4814 536645 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4815 536645 try_y = 0;
4816
2/2
✓ Branch 0 taken 519643 times.
✓ Branch 1 taken 536645 times.
1056288 for ( ; tries_y > 0; --tries_y )
4817 {
4818
4/4
✓ Branch 0 taken 528401 times.
✓ Branch 1 taken 8244 times.
✓ Branch 2 taken 522980 times.
✓ Branch 3 taken 5421 times.
1059625 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4819
2/2
✓ Branch 0 taken 2392 times.
✓ Branch 1 taken 520588 times.
522980 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4820 536645 try_y += (offgrid ? 8 : 16);
4821
2/2
✓ Branch 0 taken 519643 times.
✓ Branch 1 taken 17002 times.
536645 if (!ok) break;
4822 519643 }
4823
2/2
✓ Branch 0 taken 519643 times.
✓ Branch 1 taken 17002 times.
536645 if (!ok) break;
4824
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 519643 times.
519643 if((usehei%16)>0) //Uneven height
4825 {
4826 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4827 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4828 }
4829 519643 try_x += (offgrid ? 8 : 16);
4830 519643 }
4831
2/2
✓ Branch 0 taken 519643 times.
✓ Branch 1 taken 17002 times.
536645 if(!ok) break;
4832
1/2
✓ Branch 0 taken 519643 times.
✗ Branch 1 not taken.
519643 if((usewid%16)>0) //Uneven width
4833 {
4834 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4835 try_y = 0;
4836 for ( ; tries_y > 0; --tries_y )
4837 {
4838 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4839 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4840 try_y += (offgrid ? 8 : 16);
4841 if (!ok) break;
4842 }
4843 if (!ok) break;
4844 if((usehei%16)>0) //Uneven height
4845 {
4846 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4847 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4848 }
4849 }
4850 519643 break;
4851 }
4852 case 11:
4853 case r_down:
4854 {
4855 638123 dx = dx2+s;
4856 638123 dx = dy2+s;
4857 638123 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4858 //sv = ((isSideViewGravity())?7:0);
4859
2/2
✓ Branch 0 taken 622773 times.
✓ Branch 1 taken 638123 times.
1260896 for ( ; tries_x > 0; --tries_x )
4860 {
4861 638123 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4862 638123 try_y = 0;
4863
2/2
✓ Branch 0 taken 622773 times.
✓ Branch 1 taken 638123 times.
1260896 for ( ; tries_y > 0; --tries_y )
4864 {
4865
4/4
✓ Branch 0 taken 636612 times.
✓ Branch 1 taken 1511 times.
✓ Branch 2 taken 623840 times.
✓ Branch 3 taken 12772 times.
1261963 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4866
2/2
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 623734 times.
623840 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4867 638123 try_y += (offgrid ? 8 : 16);
4868
2/2
✓ Branch 0 taken 622773 times.
✓ Branch 1 taken 15350 times.
638123 if (!ok) break;
4869 622773 }
4870
2/2
✓ Branch 0 taken 622773 times.
✓ Branch 1 taken 15350 times.
638123 if (!ok) break;
4871
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 622773 times.
622773 if((usehei%16)>0) //Uneven height
4872 {
4873 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4874 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4875 }
4876 622773 try_x += (offgrid ? 8 : 16);
4877 622773 }
4878
2/2
✓ Branch 0 taken 622773 times.
✓ Branch 1 taken 15350 times.
638123 if(!ok) break;
4879
1/2
✓ Branch 0 taken 622773 times.
✗ Branch 1 not taken.
622773 if((usewid%16)>0) //Uneven width
4880 {
4881 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4882 try_y = 0;
4883 for ( ; tries_y > 0; --tries_y )
4884 {
4885 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4886 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4887 try_y += (offgrid ? 8 : 16);
4888 if (!ok) break;
4889 }
4890 if (!ok) break;
4891 if((usehei%16)>0) //Uneven height
4892 {
4893 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4894 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4895 }
4896 }
4897 622773 break;
4898 }
4899 case 13:
4900 case l_down:
4901 {
4902 600184 dx = dx1-s;
4903 600184 dy = dy2+s;
4904 600184 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4905 //sv = ((isSideViewGravity())?7:0);
4906
2/2
✓ Branch 0 taken 583146 times.
✓ Branch 1 taken 600184 times.
1183330 for ( ; tries_x > 0; --tries_x )
4907 {
4908 600184 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4909 600184 try_y = 0;
4910
2/2
✓ Branch 0 taken 583146 times.
✓ Branch 1 taken 600184 times.
1183330 for ( ; tries_y > 0; --tries_y )
4911 {
4912
4/4
✓ Branch 0 taken 588277 times.
✓ Branch 1 taken 11907 times.
✓ Branch 2 taken 584012 times.
✓ Branch 3 taken 4265 times.
1184196 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4913
2/2
✓ Branch 0 taken 568 times.
✓ Branch 1 taken 583444 times.
584012 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4914 600184 try_y += (offgrid ? 8 : 16);
4915
2/2
✓ Branch 0 taken 583146 times.
✓ Branch 1 taken 17038 times.
600184 if (!ok) break;
4916 583146 }
4917
2/2
✓ Branch 0 taken 583146 times.
✓ Branch 1 taken 17038 times.
600184 if (!ok) break;
4918
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 583146 times.
583146 if((usehei%16)>0) //Uneven height
4919 {
4920 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4921 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4922 }
4923 583146 try_x += (offgrid ? 8 : 16);
4924 583146 }
4925
2/2
✓ Branch 0 taken 583146 times.
✓ Branch 1 taken 17038 times.
600184 if(!ok) break;
4926
1/2
✓ Branch 0 taken 583146 times.
✗ Branch 1 not taken.
583146 if((usewid%16)>0) //Uneven width
4927 {
4928 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4929 try_y = 0;
4930 for ( ; tries_y > 0; --tries_y )
4931 {
4932 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4933 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4934 try_y += (offgrid ? 8 : 16);
4935 if (!ok) break;
4936 }
4937 if (!ok) break;
4938 if((usehei%16)>0) //Uneven height
4939 {
4940 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4941 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4942 }
4943 }
4944 583146 break;
4945 }
4946 case 15:
4947 case l_up:
4948 {
4949 564898 dx = dx1-s;
4950 564898 dy = dy1-s;
4951 564898 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4952 564898 sv = ((isSideViewGravity())?7:0);
4953
2/2
✓ Branch 0 taken 549004 times.
✓ Branch 1 taken 564898 times.
1113902 for ( ; tries_x > 0; --tries_x )
4954 {
4955 564898 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4956 564898 try_y = 0;
4957
2/2
✓ Branch 0 taken 549004 times.
✓ Branch 1 taken 564898 times.
1113902 for ( ; tries_y > 0; --tries_y )
4958 {
4959
4/4
✓ Branch 0 taken 556265 times.
✓ Branch 1 taken 8633 times.
✓ Branch 2 taken 552308 times.
✓ Branch 3 taken 3957 times.
1117206 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4960
2/2
✓ Branch 0 taken 2439 times.
✓ Branch 1 taken 549869 times.
552308 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4961 564898 try_y += (offgrid ? 8 : 16);
4962
2/2
✓ Branch 0 taken 549004 times.
✓ Branch 1 taken 15894 times.
564898 if (!ok) break;
4963 549004 }
4964
2/2
✓ Branch 0 taken 549004 times.
✓ Branch 1 taken 15894 times.
564898 if (!ok) break;
4965
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 549004 times.
549004 if((usehei%16)>0) //Uneven height
4966 {
4967 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4968 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4969 }
4970 549004 try_x += (offgrid ? 8 : 16);
4971 549004 }
4972
2/2
✓ Branch 0 taken 549004 times.
✓ Branch 1 taken 15894 times.
564898 if(!ok) break;
4973
1/2
✓ Branch 0 taken 549004 times.
✗ Branch 1 not taken.
549004 if((usewid%16)>0) //Uneven width
4974 {
4975 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4976 try_y = 0;
4977 for ( ; tries_y > 0; --tries_y )
4978 {
4979 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4980 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4981 try_y += (offgrid ? 8 : 16);
4982 if (!ok) break;
4983 }
4984 if (!ok) break;
4985 if((usehei%16)>0) //Uneven height
4986 {
4987 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4988 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4989 }
4990 }
4991 549004 break;
4992 }
4993 default:
4994 119653 db=99;
4995 119653 return true;
4996 }
4997 //Z_eventlog("\n");
4998 7204274 return ok;
4999 7325205 }
5000
5001
5002 4624265 bool enemy::canmove(int32_t ndir,zfix s,int32_t special, bool kb)
5003 {
5004
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4624265 times.
4624265 int32_t usewid = (SIZEflags&OVERRIDE_HIT_WIDTH) ? hit_width : 16;
5005
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4624265 times.
4624265 int32_t usehei = (SIZEflags&OVERRIDE_HIT_HEIGHT) ? hit_height : 16;
5006
1/2
✓ Branch 0 taken 4624265 times.
✗ Branch 1 not taken.
4624265 if (usewid % 16 != 0) usewid += (16 - (usewid%16));
5007
1/2
✓ Branch 0 taken 4624265 times.
✗ Branch 1 not taken.
4624265 if (usehei % 16 != 0) usehei += (16 - (usehei%16));
5008 4624265 --usewid;
5009 4624265 --usehei;
5010 4624265 return canmove(ndir,s,special,0,-8,usewid,usehei,kb);
5011 }
5012
5013 1243160 bool enemy::canmove(int32_t ndir,int32_t special, bool kb)
5014 {
5015 1243160 bool dodongo_move=true; //yes, it's an ugly hack, but we're going to rewrite everything later anyway - DN
5016
5017
4/4
✓ Branch 0 taken 6819 times.
✓ Branch 1 taken 1236341 times.
✓ Branch 2 taken 5021 times.
✓ Branch 3 taken 1798 times.
1243160 if(special==spw_clipright&&ndir==right)
5018 {
5019 1798 dodongo_move=canmove(ndir,(zfix)1,special,0,-8,31,15,kb);
5020 1798 }
5021
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1243155 times.
1243160 int32_t usewid = (SIZEflags&OVERRIDE_HIT_WIDTH) ? hit_width : 16;
5022
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1243155 times.
1243160 int32_t usehei = (SIZEflags&OVERRIDE_HIT_HEIGHT) ? hit_height : 16;
5023
1/2
✓ Branch 0 taken 1243160 times.
✗ Branch 1 not taken.
1243160 if (usewid % 16 != 0) usewid += (16 - (usewid%16));
5024
1/2
✓ Branch 0 taken 1243160 times.
✗ Branch 1 not taken.
1243160 if (usehei % 16 != 0) usehei += (16 - (usehei%16));
5025 1243160 --usewid;
5026 1243160 --usehei;
5027
2/2
✓ Branch 0 taken 716881 times.
✓ Branch 1 taken 526279 times.
1243160 return canmove(ndir,(zfix)1,special,0,-8,usewid,usehei,kb)&&dodongo_move;
5028 }
5029
5030 136202 bool enemy::canmove(int32_t ndir, bool kb)
5031 {
5032 136202 return canmove(ndir,(zfix)1,spw_none,0,-8,15,15,kb);
5033 }
5034
5035 // 8-directional
5036 562 void enemy::newdir_8_old(int32_t newrate,int32_t newhoming,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
5037 {
5038 562 int32_t ndir=0;
5039
5040 // can move straight, check if it wants to turn
5041
2/2
✓ Branch 0 taken 549 times.
✓ Branch 1 taken 13 times.
562 if(canmove_old(dir,step,special,dx1,dy1,dx2,dy2))
5042 {
5043
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 549 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
549 if(grumble && (zc_oldrand()&4)<grumble) //Homing
5044 {
5045 int32_t w = Lwpns.idFirst(wBait);
5046
5047 if(w>=0)
5048 {
5049 int32_t bx = Lwpns.spr(w)->x;
5050 int32_t by = Lwpns.spr(w)->y;
5051
5052 ndir = (bx<x) ? left : (bx!=x) ? right : 0;
5053
5054 if(abs(int32_t(y)-by)>14)
5055 {
5056 if(ndir>0) // Already left or right
5057 {
5058 // Making the diagonal directions
5059 ndir += (by<y) ? 2 : 4;
5060 }
5061 else
5062 {
5063 ndir = (by<y) ? up : down;
5064 }
5065 }
5066
5067 if(canmove(ndir,special,false))
5068 {
5069 dir=ndir;
5070 return;
5071 }
5072 }
5073 }
5074
5075 // Homing added.
5076
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 549 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
549 if(newhoming && (zc_oldrand()&255)<newhoming)
5077 {
5078 ndir = lined_up(8,true);
5079
5080 if(ndir>=0 && canmove(ndir,special,false))
5081 {
5082 dir=ndir;
5083 }
5084
5085 return;
5086 }
5087
5088 549 int32_t r=zc_oldrand();
5089
5090
2/4
✓ Branch 0 taken 549 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 549 times.
549 if(newrate>0 && !(r%newrate))
5091 {
5092 549 ndir = ((dir+((r&64)?-1:1))&7)+8;
5093 549 int32_t ndir2=((dir+((r&64)?1:-1))&7)+8;
5094
5095
2/2
✓ Branch 0 taken 525 times.
✓ Branch 1 taken 24 times.
549 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5096 525 dir=ndir;
5097
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 19 times.
24 else if(canmove(ndir2,step,special,dx1,dy1,dx2,dy2,false))
5098 19 dir=ndir2;
5099
5100
3/4
✓ Branch 0 taken 525 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 525 times.
✗ Branch 3 not taken.
549 if(dir==ndir && (newrate>=4)) // newrate>=4, otherwise movement is biased toward upper-left
5101 // due to numerous lost fractional components. -L
5102 {
5103 x.doFloor();
5104 y.doFloor();
5105 }
5106 549 }
5107
5108 549 return;
5109 }
5110
5111 // can't move straight, must turn
5112 13 int32_t i=0;
5113
5114
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 for(; i<32; i++) // Try random dir
5115 {
5116 20 ndir=(zc_oldrand()&7)+8;
5117
5118
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 13 times.
20 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5119 13 break;
5120 7 }
5121
5122
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(i==32)
5123 {
5124 for(ndir=8; ndir<16; ndir++)
5125 {
5126 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5127 goto ok;
5128 }
5129
5130 ndir = (isSideViewGravity()) ? (zc_oldrand()&1 ? left : right) : -1; // Sideview enemies get trapped if their dir becomes -1
5131 }
5132
5133 ok:
5134 13 dir=ndir;
5135 13 x.doFloor();
5136 13 y.doFloor();
5137 562 }
5138
5139 577113 void enemy::newdir_8(int32_t newrate,int32_t newhoming,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
5140 {
5141 577113 int32_t ndir=0;
5142
5143 // can move straight, check if it wants to turn
5144
2/2
✓ Branch 0 taken 544558 times.
✓ Branch 1 taken 32555 times.
577113 if(canmove(dir,step,special,dx1,dy1,dx2,dy2,false))
5145 {
5146
4/4
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 544351 times.
✓ Branch 2 taken 106 times.
✓ Branch 3 taken 101 times.
544558 if(grumble && (zc_oldrand()&4)<abs(grumble)) //Homing
5147 {
5148 101 int32_t i = Lwpns.idFirst(wBait);
5149
1/2
✓ Branch 0 taken 101 times.
✗ Branch 1 not taken.
101 if(i >= 0) //idfirst returns -1 if it can't find any
5150 {
5151 weapon *w = (weapon*)Lwpns.spr(i);
5152 if (get_qr(qr_FIND_CLOSEST_BAIT))
5153 {
5154 int32_t currentrange;
5155 if (distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0) currentrange = distance(x, y, w->x, w->y);
5156 else currentrange = -1;
5157 int curid = i;
5158 ++i; //increment beforehand cause we just checked the first bait weapon and all others must be after it. ...otherwise it wouldn't be the first. -Deedee
5159 for(; i<Lwpns.Count(); ++i)
5160 {
5161 weapon *lw = (weapon*)Lwpns.spr(i);
5162 if (lw->id == wBait && distance(x, y, lw->x, lw->y) < currentrange && (distance(x, y, lw->x, lw->y) < lw->misc2 || lw->misc2 == 0))
5163 {
5164 currentrange = distance(x, y, lw->x, lw->y);
5165 curid = i;
5166 }
5167 }
5168 i = curid;
5169 if (currentrange == -1) i = -1;
5170 }
5171 else
5172 {
5173 if (!(distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0)) i = -1;
5174 }
5175 if(i>=0)
5176 {
5177 int32_t bx = Lwpns.spr(i)->x;
5178 int32_t by = Lwpns.spr(i)->y;
5179
5180 ndir = (bx<x) ? left : (bx!=x) ? right : 0;
5181
5182 if(abs(int32_t(y)-by)>14)
5183 {
5184 if(ndir>0) // Already left or right
5185 {
5186 // Making the diagonal directions
5187 ndir += (by<y) ? 2 : 4;
5188 }
5189 else
5190 {
5191 ndir = (by<y) ? up : down;
5192 }
5193 }
5194 if (grumble < 0 || (itemsbuf[((weapon*)Lwpns.spr(i))->parentitem].flags & item_flag1)) ndir = oppositeDir[ndir];
5195 if(canmove(ndir,special,false))
5196 {
5197 dir=ndir;
5198 return;
5199 }
5200 }
5201 }
5202 101 }
5203
5204 // Homing added.
5205
4/4
✓ Branch 0 taken 29626 times.
✓ Branch 1 taken 514932 times.
✓ Branch 2 taken 15410 times.
✓ Branch 3 taken 14216 times.
544558 if(newhoming && (zc_oldrand()&255)<abs(newhoming))
5206 {
5207 14216 ndir = lined_up(8,true);
5208
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14216 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14216 if (newhoming < 0 && ndir >= 0) ndir = oppositeDir[ndir];
5209
4/4
✓ Branch 0 taken 9445 times.
✓ Branch 1 taken 4771 times.
✓ Branch 2 taken 3593 times.
✓ Branch 3 taken 5852 times.
14216 if(ndir>=0 && canmove(ndir,special,false))
5210 {
5211 5852 dir=ndir;
5212 5852 }
5213
5214 14216 return;
5215 }
5216
5217 530342 int32_t r=zc_oldrand();
5218
5219
4/4
✓ Branch 0 taken 338430 times.
✓ Branch 1 taken 191912 times.
✓ Branch 2 taken 178921 times.
✓ Branch 3 taken 159509 times.
530342 if(newrate>0 && !(r%newrate))
5220 {
5221 159509 ndir = ((dir+((r&64)?-1:1))&7)+8;
5222 159509 int32_t ndir2=((dir+((r&64)?1:-1))&7)+8;
5223
5224
2/2
✓ Branch 0 taken 153722 times.
✓ Branch 1 taken 5787 times.
159509 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5225 153722 dir=ndir;
5226
2/2
✓ Branch 0 taken 857 times.
✓ Branch 1 taken 4930 times.
5787 else if(canmove(ndir2,step,special,dx1,dy1,dx2,dy2,false))
5227 4930 dir=ndir2;
5228
5229
4/4
✓ Branch 0 taken 153722 times.
✓ Branch 1 taken 5787 times.
✓ Branch 2 taken 146396 times.
✓ Branch 3 taken 7326 times.
159509 if(dir==ndir && (newrate>=4)) // newrate>=4, otherwise movement is biased toward upper-left
5230 // due to numerous lost fractional components. -L
5231 {
5232 7326 x.doFloor();
5233 7326 y.doFloor();
5234 7326 }
5235 159509 }
5236
5237 530342 return;
5238 }
5239
5240 // can't move straight, must turn
5241 32555 int32_t i=0;
5242
5243
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 60993 times.
61063 for(; i<32; i++) // Try random dir
5244 {
5245 60993 ndir=(zc_oldrand()&7)+8;
5246
5247
2/2
✓ Branch 0 taken 28508 times.
✓ Branch 1 taken 32485 times.
60993 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5248 32485 break;
5249 28508 }
5250
5251
2/2
✓ Branch 0 taken 32485 times.
✓ Branch 1 taken 70 times.
32608 if(i==32)
5252 {
5253
2/2
✓ Branch 0 taken 461 times.
✓ Branch 1 taken 53 times.
514 for(ndir=8; ndir<16; ndir++)
5254 {
5255
2/2
✓ Branch 0 taken 444 times.
✓ Branch 1 taken 17 times.
461 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5256 17 goto ok;
5257 444 }
5258
5259
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 ndir = (isSideViewGravity()) ? (zc_oldrand()&1 ? left : right) : -1; // Sideview enemies get trapped if their dir becomes -1
5260 53 }
5261
5262 ok:
5263 32555 dir=ndir;
5264 32555 x.doFloor();
5265 32555 y.doFloor();
5266 577113 }
5267
5268 570638 void enemy::newdir_8(int32_t newrate,int32_t newhoming,int32_t special)
5269 {
5270 570638 newdir_8(newrate,newhoming,special,0,-8,15,15);
5271 570638 }
5272
5273 562 void enemy::newdir_8_old(int32_t newrate,int32_t newhoming,int32_t special)
5274 {
5275 562 newdir_8_old(newrate,newhoming,special,0,-8,15,15);
5276 562 }
5277
5278 // makes the enemy slide backwards when hit
5279 // sclk: first byte is clk, second byte is dir
5280 // makes the enemy slide backwards when hit
5281 // sclk: first byte is clk, second byte is dir
5282 15625749 int32_t enemy::slide()
5283 {
5284
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15625749 times.
15625749 if(script_knockback_clk!=0) //scripted knockback
5285 {
5286 sclk = 0;
5287 return 1; //scripted knockback ran
5288 }
5289
5/6
✓ Branch 0 taken 102071 times.
✓ Branch 1 taken 15523678 times.
✓ Branch 2 taken 7848 times.
✓ Branch 3 taken 94223 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 7848 times.
15625749 if(sclk==0 || (hp<=0 && !immortal))
5290 15531526 return 0;
5291
5292
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94223 times.
94223 if(knockbackflags & FLAG_NOSLIDE)
5293 {
5294 sclk = 0;
5295 if(!OFFGRID_ENEMY)
5296 {
5297 //Fix to grid
5298 //x = (int32_t(x)+8)-((int32_t(x)+8)%16);
5299 //y = (int32_t(y)+8)-((int32_t(y)+8)%16);
5300 do_fix(x, 16, true);
5301 do_fix(y, 16, true);
5302 }
5303 return 0;
5304 }
5305
8/10
✓ Branch 0 taken 9551 times.
✓ Branch 1 taken 84672 times.
✓ Branch 2 taken 296 times.
✓ Branch 3 taken 9255 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 296 times.
✓ Branch 6 taken 7103 times.
✓ Branch 7 taken 2152 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 296 times.
94223 if((sclk&255)==16 && (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION) || knockbackSpeed!=4 ? !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : 12),0,true) : !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : knockbackSpeed),0,0,0,15,15,true)))
5306 {
5307 2152 sclk=0;
5308 2152 return 0;
5309 }
5310
5311 92071 --sclk;
5312
5313
5/5
✓ Branch 0 taken 1785 times.
✓ Branch 1 taken 10539 times.
✓ Branch 2 taken 12291 times.
✓ Branch 3 taken 31734 times.
✓ Branch 4 taken 35722 times.
92071 switch(sclk>>8)
5314 {
5315 case up:
5316 {
5317
4/4
✓ Branch 0 taken 1090 times.
✓ Branch 1 taken 9449 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 10532 times.
10539 if(y<=(dmisc2==e2tSPLITHIT ? 0 : (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION)?16:0))) //vires
5318 {
5319 7 sclk=0;
5320 7 return 0;
5321 }
5322
4/4
✓ Branch 0 taken 1090 times.
✓ Branch 1 taken 9442 times.
✓ Branch 2 taken 915 times.
✓ Branch 3 taken 175 times.
10532 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; } //vires
5323
5324 10357 break;
5325 }
5326 case down:
5327 {
5328
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 12289 times.
12291 if(y>=(dmisc2==e2tSPLITHIT ? 150 : 160)) //was 160 --changed for vires bug.
5329 {
5330 2 sclk=0;
5331 2 return 0;
5332 }
5333
4/4
✓ Branch 0 taken 1069 times.
✓ Branch 1 taken 11220 times.
✓ Branch 2 taken 923 times.
✓ Branch 3 taken 146 times.
12289 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; } //vires
5334
5335 12143 break;
5336 }
5337 case left:
5338 {
5339
4/4
✓ Branch 0 taken 2354 times.
✓ Branch 1 taken 29380 times.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 31721 times.
31734 if(x<=(dmisc2==e2tSPLITHIT ? 0 : (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION)?16:0)))
5340 {
5341 13 sclk=0;
5342 13 return 0;
5343 }
5344
4/4
✓ Branch 0 taken 2354 times.
✓ Branch 1 taken 29367 times.
✓ Branch 2 taken 2116 times.
✓ Branch 3 taken 238 times.
31721 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; }
5345
5346 31483 break;
5347 }
5348 case right:
5349 {
5350
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35722 times.
35722 if(x>=(dmisc2==e2tSPLITHIT ? 255 : 240)) //vires
5351 {
5352 sclk=0;
5353 return 0;
5354 }
5355
4/4
✓ Branch 0 taken 3288 times.
✓ Branch 1 taken 32434 times.
✓ Branch 2 taken 3018 times.
✓ Branch 3 taken 270 times.
35722 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; } //vires
5356 35452 break;
5357 }
5358 }
5359
5360 91220 int32_t move = knockbackSpeed;
5361
2/2
✓ Branch 0 taken 86337 times.
✓ Branch 1 taken 91220 times.
177557 while(move>0)
5362 {
5363
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 91220 times.
91220 int32_t thismove = zc_min(8, move);
5364 91220 move -= thismove;
5365 91220 hitdir = (sclk>>8);
5366
5/5
✓ Branch 0 taken 1785 times.
✓ Branch 1 taken 10357 times.
✓ Branch 2 taken 12143 times.
✓ Branch 3 taken 31483 times.
✓ Branch 4 taken 35452 times.
91220 switch(sclk>>8)
5367 {
5368 case up:
5369 10357 y-=thismove;
5370 10357 break;
5371
5372 case down:
5373 12143 y+=thismove;
5374 12143 break;
5375
5376 case left:
5377 31483 x-=thismove;
5378 31483 break;
5379
5380 case right:
5381 35452 x+=thismove;
5382 35452 break;
5383 }
5384
2/2
✓ Branch 0 taken 86337 times.
✓ Branch 1 taken 4883 times.
91220 if(!canmove(sclk>>8,(zfix)0,0,true))
5385 {
5386
3/3
✓ Branch 0 taken 1973 times.
✓ Branch 1 taken 2906 times.
✓ Branch 2 taken 4 times.
4883 switch(sclk>>8)
5387 {
5388 case up:
5389 case down:
5390
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1973 times.
1973 if(y < 0)
5391 y = 0;
5392
2/2
✓ Branch 0 taken 325 times.
✓ Branch 1 taken 1648 times.
1973 else if((int32_t(y)&15) > 7)
5393 325 y=(int32_t(y)&0xF0)+16;
5394 else
5395 1648 y=(int32_t(y)&0xF0);
5396
5397 1973 break;
5398
5399 case left:
5400 case right:
5401
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2902 times.
2906 if(x < 0)
5402 4 x = 0;
5403
2/2
✓ Branch 0 taken 833 times.
✓ Branch 1 taken 2069 times.
2902 else if((int32_t(x)&15) > 7)
5404 833 x=(int32_t(x)&0xF0)+16;
5405 else
5406 2069 x=(int32_t(x)&0xF0);
5407
5408 2906 break;
5409 }
5410
5411 4883 sclk=0;
5412 4883 clk3=0;
5413 4883 break;
5414 }
5415 }
5416
5417
2/2
✓ Branch 0 taken 83859 times.
✓ Branch 1 taken 7361 times.
91220 if((sclk&255)==0)
5418 {
5419 //hitdir = -1;
5420 7361 sclk=0;
5421 7361 }
5422 91220 return 2;
5423 15625749 }
5424
5425 bool enemy::can_slide()
5426 {
5427 if(sclk==0 || (hp<=0 && !immortal))
5428 return false;
5429
5430 if((sclk&255)==16 && (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION) || knockbackSpeed!=4 ? !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : 12),0,true) : !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : knockbackSpeed),0,true)))
5431 {
5432 return false;
5433 }
5434
5435 return true;
5436 }
5437
5438 bool enemy::fslide()
5439 {
5440 if(sclk==0 || (hp<=0 && !immortal))
5441 return false;
5442
5443 if((sclk&255)==16 && !canmove(sclk>>8,(zfix)12,spw_floater,true))
5444 {
5445 sclk=0;
5446 return false;
5447 }
5448
5449 --sclk;
5450
5451 switch(sclk>>8)
5452 {
5453 case up:
5454 if(y<=16)
5455 {
5456 sclk=0;
5457 return false;
5458 }
5459
5460 break;
5461
5462 case down:
5463 if(y>=160)
5464 {
5465 sclk=0;
5466 return false;
5467 }
5468
5469 break;
5470
5471 case left:
5472 if(x<=16)
5473 {
5474 sclk=0;
5475 return false;
5476 }
5477
5478 break;
5479
5480 case right:
5481 if(x>=240)
5482 {
5483 sclk=0;
5484 return false;
5485 }
5486
5487 break;
5488 }
5489 hitdir = (sclk>>8);
5490 switch(sclk>>8)
5491 {
5492 case up:
5493 y-=4;
5494 break;
5495
5496 case down:
5497 y+=4;
5498 break;
5499
5500 case left:
5501 x-=4;
5502 break;
5503
5504 case right:
5505 x+=4;
5506 break;
5507 }
5508
5509 if(!canmove(sclk>>8,(zfix)0,spw_floater,true))
5510 {
5511 switch(sclk>>8)
5512 {
5513 case up:
5514 case down:
5515 if((int32_t(y)&15) > 7)
5516 y=(int32_t(y)&0xF0)+16;
5517 else
5518 y=(int32_t(y)&0xF0);
5519
5520 break;
5521
5522 case left:
5523 case right:
5524 if((int32_t(x)&15) > 7)
5525 x=(int32_t(x)&0xF0)+16;
5526 else
5527 x=(int32_t(x)&0xF0);
5528
5529 break;
5530 }
5531
5532 sclk=0;
5533 clk3=0;
5534 }
5535
5536 if((sclk&255)==0)
5537 sclk=0;
5538
5539 return true;
5540 }
5541
5542 bool enemy::knockback(int32_t time, int32_t dir, int32_t speed)
5543 {
5544 if((hp<=0 && !immortal)) return false; //No knocking back dead/mid-knockback enemies
5545 if(!canmove(dir,(zfix)speed,0,0,0,15,15,true)) return false; //from slide(); collision check
5546 bool ret = sprite::knockback(time, dir, speed);
5547 if(ret) sclk = 0; //kill engine knockback if interrupted
5548 //! Perhaps also set hitdir here, if needed for timing? -Z
5549 return ret;
5550 }
5551
5552 37829376 bool enemy::runKnockback()
5553 {
5554
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37829376 times.
37829376 if((script_knockback_clk&0xFF)==0)
5555 {
5556 37829376 script_knockback_clk = 0;
5557 37829376 return false;
5558 }
5559 if(knockbackflags & FLAG_NOSCRIPTKNOCKBACK)
5560 {
5561 return false;
5562 }
5563 int32_t move = script_knockback_speed;
5564 int32_t kb_dir = script_knockback_clk>>8;
5565 --script_knockback_clk;
5566
5567 while(move>0)
5568 {
5569 int32_t thismove = zc_min(get_qr(qr_OLD_SCRIPTED_KNOCKBACK)?8:4, move);
5570 move -= thismove;
5571 hitdir = kb_dir;
5572 switch(kb_dir)
5573 {
5574 case r_up:
5575 case l_up:
5576 case up:
5577 y-=thismove;
5578 break;
5579
5580 case r_down:
5581 case l_down:
5582 case down:
5583 y+=thismove;
5584 break;
5585 }
5586 switch(kb_dir)
5587 {
5588 case l_up:
5589 case l_down:
5590 case left:
5591 x-=thismove;
5592 break;
5593
5594 case r_up:
5595 case r_down:
5596 case right:
5597 x+=thismove;
5598 break;
5599 }
5600 if (get_qr(qr_OLD_SCRIPTED_KNOCKBACK))
5601 {
5602 if(!canmove(kb_dir,(zfix)0,0,true))
5603 {
5604 script_knockback_clk=0;
5605 clk3=0;
5606 //Fix to grid
5607 switch(kb_dir)
5608 {
5609 case up:
5610 case down:
5611 break;
5612 default:
5613 if(x < 0)
5614 x = 0;
5615 else if((int32_t(x)&15) > 7)
5616 x=(int32_t(x)&0xF0)+16;
5617 else
5618 x=(int32_t(x)&0xF0);
5619 break;
5620 }
5621 switch(kb_dir)
5622 {
5623 case left:
5624 case right:
5625 break;
5626 default:
5627 if(y < 0)
5628 y = 0;
5629 else if((int32_t(y)&15) > 7)
5630 y=(int32_t(y)&0xF0)+16;
5631 else
5632 y=(int32_t(y)&0xF0);
5633 break;
5634 }
5635 break;
5636 }
5637 }
5638 else
5639 {
5640 if(!scr_canplace(x,y,0,true))
5641 {
5642 script_knockback_clk=0;
5643 clk3=0;
5644 //Fix to grid
5645 if (OFFGRID_ENEMY)
5646 {
5647 switch(kb_dir)
5648 {
5649 case up:
5650 case down:
5651 break;
5652 default:
5653 if(x < 0)
5654 x = 0;
5655 else if((int32_t(x)&7) > 3)
5656 x=(int32_t(x)&0xF8)+8;
5657 else
5658 x=(int32_t(x)&0xF8);
5659 break;
5660 }
5661 switch(kb_dir)
5662 {
5663 case left:
5664 case right:
5665 break;
5666 default:
5667 if(y < 0)
5668 y = 0;
5669 else if((int32_t(y)&7) > 3)
5670 y=(int32_t(y)&0xF8)+8;
5671 else
5672 y=(int32_t(y)&0xF8);
5673 break;
5674 }
5675 }
5676 else
5677 {
5678 switch(kb_dir)
5679 {
5680 case up:
5681 case down:
5682 break;
5683 default:
5684 if(x < 0)
5685 x = 0;
5686 else if((int32_t(x)&15) > 7)
5687 x=(int32_t(x)&0xF0)+16;
5688 else
5689 x=(int32_t(x)&0xF0);
5690 break;
5691 }
5692 switch(kb_dir)
5693 {
5694 case left:
5695 case right:
5696 break;
5697 default:
5698 if(y < 0)
5699 y = 0;
5700 else if((int32_t(y)&15) > 7)
5701 y=(int32_t(y)&0xF0)+16;
5702 else
5703 y=(int32_t(y)&0xF0);
5704 break;
5705 }
5706 }
5707 break;
5708 }
5709
5710 }
5711 }
5712 return true;
5713 37829376 }
5714 // changes enemy's direction, checking restrictions
5715 // rate: 0 = no random changes, 16 = always random change
5716 // homing: 0 = none, 256 = always
5717 // grumble 0 = none, 4 = strongest appetite
5718 520320 void enemy::newdir(int32_t newrate,int32_t newhoming,int32_t special)
5719 {
5720 520320 int32_t ndir=-1;
5721
5722
4/4
✓ Branch 0 taken 109954 times.
✓ Branch 1 taken 410366 times.
✓ Branch 2 taken 37802 times.
✓ Branch 3 taken 72152 times.
520320 if(grumble != 0 && (zc_oldrand()&3)<abs(grumble)) //yes, I know checking if grumble is equal to if grumble == 0, but the latter makes the intention more clear to less experienced coders who might join.
5723 {
5724 72152 int32_t i = Lwpns.idFirst(wBait);
5725
1/2
✓ Branch 0 taken 72152 times.
✗ Branch 1 not taken.
72152 if(i >= 0) //idfirst returns -1 if it can't find any
5726 {
5727 weapon *w = (weapon*)Lwpns.spr(i);
5728 if (get_qr(qr_FIND_CLOSEST_BAIT))
5729 {
5730 int32_t currentrange;
5731 if (distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0) currentrange = distance(x, y, w->x, w->y);
5732 else currentrange = -1;
5733 int curid = i;
5734 ++i; //increment beforehand cause we just checked the first bait weapon and all others must be after it. ...otherwise it wouldn't be the first. -Deedee
5735 for(; i<Lwpns.Count(); ++i)
5736 {
5737 weapon *lw = (weapon*)Lwpns.spr(i);
5738 if (lw->id == wBait && distance(x, y, lw->x, lw->y) < currentrange && (distance(x, y, lw->x, lw->y) < lw->misc2 || lw->misc2 == 0))
5739 {
5740 currentrange = distance(x, y, lw->x, lw->y);
5741 curid = i;
5742 }
5743 }
5744 i = curid;
5745 if (currentrange == -1) i = -1;
5746 }
5747 else
5748 {
5749 if (!(distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0)) i = -1;
5750 }
5751 if (i >= 0)
5752 {
5753 int32_t bx = Lwpns.spr(i)->x;
5754 int32_t by = Lwpns.spr(i)->y;
5755
5756 if(abs(int32_t(y)-by)>14)
5757 {
5758 ndir = (by<y) ? up : down;
5759 if (grumble < 0 || (itemsbuf[((weapon*)Lwpns.spr(i))->parentitem].flags & item_flag1)) ndir = oppositeDir[ndir];
5760 if(canmove(ndir,special,false))
5761 {
5762 dir=ndir;
5763 return;
5764 }
5765 }
5766
5767 ndir = (bx<x) ? left : right;
5768 if (grumble < 0 || (itemsbuf[((weapon*)Lwpns.spr(i))->parentitem].flags & item_flag1)) ndir = oppositeDir[ndir];
5769 if(canmove(ndir,special,false))
5770 {
5771 dir=ndir;
5772 return;
5773 }
5774 }
5775 }
5776 72152 }
5777
5778
2/2
✓ Branch 0 taken 352450 times.
✓ Branch 1 taken 167870 times.
520320 if((zc_oldrand()&255)<abs(newhoming))
5779 {
5780 167870 ndir = lined_up(8,false);
5781
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 167870 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
167870 if (newhoming < 0 && ndir >= 0) ndir = oppositeDir[ndir];
5782
4/4
✓ Branch 0 taken 45336 times.
✓ Branch 1 taken 122534 times.
✓ Branch 2 taken 5715 times.
✓ Branch 3 taken 39621 times.
167870 if(ndir>=0 && canmove(ndir,special,false))
5783 {
5784 39621 dir=ndir;
5785 39621 return;
5786 }
5787 128249 }
5788
5789 480699 int32_t i=0;
5790
5791
2/2
✓ Branch 0 taken 3335 times.
✓ Branch 1 taken 1179460 times.
1182795 for(; i<32; i++)
5792 {
5793 1179460 int32_t r=zc_oldrand();
5794
5795
2/2
✓ Branch 0 taken 344661 times.
✓ Branch 1 taken 834799 times.
1179460 if((r&15)<newrate)
5796 344661 ndir=(r>>4)&3;
5797 else
5798 834799 ndir=dir;
5799
5800
2/2
✓ Branch 0 taken 702096 times.
✓ Branch 1 taken 477364 times.
1179460 if(canmove(ndir,special,false))
5801 477364 break;
5802 702096 }
5803
5804
2/2
✓ Branch 0 taken 477364 times.
✓ Branch 1 taken 3335 times.
481452 if(i==32)
5805 {
5806
2/2
✓ Branch 0 taken 8919 times.
✓ Branch 1 taken 753 times.
9672 for(ndir=0; ndir<4; ndir++)
5807 {
5808
2/2
✓ Branch 0 taken 6337 times.
✓ Branch 1 taken 2582 times.
8919 if(canmove(ndir,special,false))
5809 2582 goto ok;
5810 6337 }
5811
5812
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 693 times.
753 ndir = (isSideViewGravity()) ? (zc_oldrand()&1 ? left : right) : -1; // Sideview enemies get trapped if their dir becomes -1
5813 //...Isn't that the point? I'm not sure I understand. Certainly beats phasing through walls... -Dimi
5814 753 }
5815
5816 ok:
5817 480699 dir = ndir;
5818 520320 }
5819
5820 2634 void enemy::newdir()
5821 {
5822 2634 newdir(4,0,spw_none);
5823 2634 }
5824
5825 zfix enemy::distance_left()
5826 {
5827 int32_t a2=x.getInt();
5828 int32_t b2=y.getInt();
5829
5830 switch(dir)
5831 {
5832 case up:
5833 return (zfix)(b2&0xF);
5834
5835 case down:
5836 return (zfix)(16-(b2&0xF));
5837
5838 case left:
5839 return (zfix)(a2&0xF);
5840
5841 case right:
5842 return (zfix)(16-(a2&0xF));
5843 }
5844
5845 return (zfix)0;
5846 }
5847
5848 // keeps walking around
5849 391434 void enemy::constant_walk(int32_t newrate,int32_t newhoming,int32_t special)
5850 {
5851
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 391434 times.
391434 if(slide())
5852 return;
5853
5854
8/12
✓ Branch 0 taken 387600 times.
✓ Branch 1 taken 3834 times.
✓ Branch 2 taken 387600 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 383173 times.
✓ Branch 5 taken 4427 times.
✓ Branch 6 taken 383173 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 383173 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 383173 times.
391434 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock )
5855 8261 return;
5856
5857
2/2
✓ Branch 0 taken 26115 times.
✓ Branch 1 taken 357058 times.
383173 if(clk3<=0)
5858 {
5859 26115 fix_coords(true);
5860 26115 newdir(newrate,newhoming,special);
5861
5862
1/2
✓ Branch 0 taken 26115 times.
✗ Branch 1 not taken.
26115 if(step==0)
5863 clk3=0;
5864 else
5865 26115 clk3=int32_t(16.0/step);
5866 26115 }
5867
2/2
✓ Branch 0 taken 357013 times.
✓ Branch 1 taken 45 times.
357058 else if(scored)
5868 {
5869 45 dir^=1;
5870
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
45 if (step != 0) clk3=int32_t(16.0/step)-clk3;
5871 else clk3=32767;
5872 45 }
5873
5874
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 383173 times.
383173 if (step != 0) --clk3;
5875 383173 move(step);
5876 391434 }
5877
5878 void enemy::constant_walk()
5879 {
5880 constant_walk(4,0,spw_none);
5881 }
5882
5883 35220 int32_t enemy::pos(int32_t newx,int32_t newy)
5884 {
5885 35220 return (newy<<8)+newx;
5886 }
5887
5888 // for variable step rates
5889 473814 void enemy::variable_walk(int32_t newrate,int32_t newhoming,int32_t special)
5890 {
5891
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 473814 times.
473814 if(slide())
5892 return;
5893
5894
10/14
✓ Branch 0 taken 473814 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 473814 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 465189 times.
✓ Branch 5 taken 8625 times.
✓ Branch 6 taken 455915 times.
✓ Branch 7 taken 9274 times.
✓ Branch 8 taken 418370 times.
✓ Branch 9 taken 37545 times.
✓ Branch 10 taken 418370 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 418370 times.
✗ Branch 13 not taken.
473814 if(clk<0 || dying || stunclk || watch || step == 0 || ceiling || frozenclock )
5895 55444 return;
5896
5897 418370 zfix dx = (zfix)0;
5898 418370 zfix dy = (zfix)0;
5899
5900
5/9
✓ Branch 0 taken 93441 times.
✓ Branch 1 taken 97752 times.
✓ Branch 2 taken 111603 times.
✓ Branch 3 taken 113743 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 1831 times.
418370 switch(dir)
5901 {
5902 case 8:
5903 case up:
5904 93441 dy-=step;
5905 93441 break;
5906
5907 case 12:
5908 case down:
5909 97752 dy+=step;
5910 97752 break;
5911
5912 case 14:
5913 case left:
5914 111603 dx-=step;
5915 111603 break;
5916
5917 case 10:
5918 case right:
5919 113743 dx+=step;
5920 113743 break;
5921
5922 case 15:
5923 case l_up:
5924 dx-=step;
5925 dy-=step;
5926 break;
5927
5928 case 9:
5929 case r_up:
5930 dx+=step;
5931 dy-=step;
5932 break;
5933
5934 case 13:
5935 case l_down:
5936 dx-=step;
5937 dy+=step;
5938 break;
5939
5940 case 11:
5941 case r_down:
5942 dx+=step;
5943 dy+=step;
5944 break;
5945 }
5946
5947
8/8
✓ Branch 0 taken 204198 times.
✓ Branch 1 taken 214172 times.
✓ Branch 2 taken 22777 times.
✓ Branch 3 taken 181421 times.
✓ Branch 4 taken 11556 times.
✓ Branch 5 taken 11221 times.
✓ Branch 6 taken 405927 times.
✓ Branch 7 taken 12443 times.
418370 if(((int32_t(x)&15)==0 && (int32_t(y)&15)==0 && clk3!=pos(x,y)) ||
5948 406814 m_walkflag(int32_t(x+dx),int32_t(y+dy), spw_halfstep, dir))
5949 {
5950 12443 fix_coords();
5951 12443 newdir(newrate,newhoming,special);
5952 12443 clk3=pos(x,y);
5953 12443 }
5954
5955 418370 move(step);
5956 473814 }
5957
5958 // pauses for a while after it makes a complete move (to a new square)
5959 12316970 void enemy::halting_walk(int32_t newrate,int32_t newhoming,int32_t special,int32_t newhrate, int32_t haltcnt)
5960 {
5961
4/4
✓ Branch 0 taken 79858 times.
✓ Branch 1 taken 12237112 times.
✓ Branch 2 taken 67026 times.
✓ Branch 3 taken 12832 times.
12316970 if(sclk && clk2)
5962 {
5963 12832 clk3=0;
5964 12832 }
5965
5966
11/14
✓ Branch 0 taken 12243978 times.
✓ Branch 1 taken 72992 times.
✓ Branch 2 taken 12243978 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12243978 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 11776810 times.
✓ Branch 7 taken 467168 times.
✓ Branch 8 taken 11639061 times.
✓ Branch 9 taken 137749 times.
✓ Branch 10 taken 11635853 times.
✓ Branch 11 taken 3208 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 11635853 times.
12316970 if(slide() || clk<0 || dying || stunclk || watch || ceiling || frozenclock)
5967 {
5968 681117 return;
5969 }
5970
5971
2/2
✓ Branch 0 taken 2132459 times.
✓ Branch 1 taken 9503394 times.
11635853 if(clk2>0)
5972 {
5973 2132459 --clk2;
5974 2132459 return;
5975 }
5976
5977
2/2
✓ Branch 0 taken 410612 times.
✓ Branch 1 taken 9092782 times.
9503394 if(clk3<=0)
5978 {
5979 410612 fix_coords(true);
5980 410612 newdir(newrate,newhoming,special);
5981 410612 clk3=int32_t(16.0/step);
5982
2/2
✓ Branch 0 taken 410415 times.
✓ Branch 1 taken 197 times.
410612 if (step == 0) clk3 = 32767; //It used to return this in 2.53 and I'm unsure why; I'm guessing dividing by 0 gave max int? Either way, can't be 0 here or scripts break.
5983
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 410612 times.
410612 if(clk2<0)
5984 {
5985 clk2=0;
5986 }
5987
2/2
✓ Branch 0 taken 54758 times.
✓ Branch 1 taken 355854 times.
410612 else if((zc_oldrand()&15)<newhrate)
5988 {
5989 54758 clk2=haltcnt;
5990 54758 return;
5991 }
5992 355854 }
5993
2/2
✓ Branch 0 taken 9089623 times.
✓ Branch 1 taken 3159 times.
9092782 else if(scored)
5994 {
5995 3159 dir^=1;
5996
5997
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 3154 times.
3159 if (step != 0) clk3=int32_t(16.0/step)-clk3;
5998 5 else clk3=32767;
5999 3159 }
6000
6001
2/2
✓ Branch 0 taken 76939 times.
✓ Branch 1 taken 9371697 times.
9448636 if (step != 0) --clk3;
6002 9448636 move(step);
6003 12316970 }
6004
6005 // 8-directional movement, aligns to 8 pixels
6006 void enemy::constant_walk_8(int32_t newrate,int32_t newhoming,int32_t special)
6007 {
6008 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
6009 return;
6010
6011 if(clk3<=0)
6012 {
6013 newdir_8(newrate,newhoming,special);
6014 clk3=int32_t(8.0/step);
6015 if (step == 0) clk3 = 32767;
6016 }
6017
6018 if (step != 0) --clk3;
6019 move(step);
6020 }
6021 // 8-directional movement, aligns to 8 pixels
6022 242393 void enemy::constant_walk_8_old(int32_t newrate,int32_t newhoming,int32_t special)
6023 {
6024
6/12
✓ Branch 0 taken 242393 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 242393 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 242393 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 242393 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 242393 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 242393 times.
242393 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
6025 return;
6026
6027
2/2
✓ Branch 0 taken 226158 times.
✓ Branch 1 taken 16235 times.
242393 if(clk3<=0)
6028 {
6029 16235 newdir_8(newrate,newhoming,special);
6030 16235 clk3=int32_t(8.0/step);
6031
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16235 times.
16235 if (step == 0) clk3 = 32767;
6032 16235 }
6033
6034
1/2
✓ Branch 0 taken 242393 times.
✗ Branch 1 not taken.
242393 if (step != 0) --clk3;
6035 242393 move(step);
6036 242393 }
6037
6038 void enemy::halting_walk_8(int32_t newrate,int32_t newhoming, int32_t newclk,int32_t special,int32_t newhrate, int32_t haltcnt)
6039 {
6040 if(clk<0 || dying || stunclk || watch || frozenclock)
6041 return;
6042
6043 if(!canmove(dir,step,special,false))
6044 clk3=0;
6045
6046 if(clk2>0)
6047 {
6048 --clk2;
6049 return;
6050 }
6051
6052 if(clk3<=0)
6053 {
6054 newdir_8(newrate,newhoming,special);
6055 clk3=newclk;
6056
6057 if(clk2<0)
6058 {
6059 clk2=0;
6060 }
6061 else if((zc_oldrand()&15)<newhrate)
6062 {
6063 newdir_8(newrate,newhoming,special);
6064 clk2=haltcnt;
6065 return;
6066 }
6067 }
6068
6069 --clk3;
6070 move(step);
6071 }
6072
6073 // 8-directional movement, no alignment
6074 4691075 void enemy::variable_walk_8(int32_t newrate,int32_t newhoming, int32_t newclk,int32_t special)
6075 {
6076
9/12
✓ Branch 0 taken 4483752 times.
✓ Branch 1 taken 207323 times.
✓ Branch 2 taken 4483752 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4457131 times.
✓ Branch 5 taken 26621 times.
✓ Branch 6 taken 4446084 times.
✓ Branch 7 taken 11047 times.
✓ Branch 8 taken 4446084 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 4446084 times.
4691075 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
6077 244991 return;
6078
6079
2/2
✓ Branch 0 taken 4415704 times.
✓ Branch 1 taken 30380 times.
4446084 if(!canmove(dir,step,special,false))
6080 30380 clk3=0;
6081
6082
2/2
✓ Branch 0 taken 3891681 times.
✓ Branch 1 taken 554403 times.
4446084 if(clk3<=0)
6083 {
6084 554403 newdir_8(newrate,newhoming,special);
6085 554403 clk3=newclk;
6086 554403 }
6087
6088 4446084 --clk3;
6089 4446084 move(step);
6090 4691075 }
6091
6092 // same as above but with variable enemy size
6093 94563 void enemy::variable_walk_8(int32_t newrate,int32_t newhoming, int32_t newclk,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
6094 {
6095
8/12
✓ Branch 0 taken 93367 times.
✓ Branch 1 taken 1196 times.
✓ Branch 2 taken 93367 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 93367 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 93316 times.
✓ Branch 7 taken 51 times.
✓ Branch 8 taken 93316 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 93316 times.
94563 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
6096 1247 return;
6097
6098
2/2
✓ Branch 0 taken 91982 times.
✓ Branch 1 taken 1334 times.
93316 if(!canmove(dir,step,special,dx1,dy1,dx2,dy2,false))
6099 1334 clk3=0;
6100
6101
2/2
✓ Branch 0 taken 86841 times.
✓ Branch 1 taken 6475 times.
93316 if(clk3<=0)
6102 {
6103 6475 newdir_8(newrate,newhoming,special,dx1,dy1,dx2,dy2);
6104 6475 clk3=newclk;
6105 6475 }
6106
6107 93316 --clk3;
6108 93316 move(step);
6109 94563 }
6110
6111 // the variable speed floater movement
6112 // ms is max speed
6113 // ss is step speed
6114 // s is step count
6115 // p is pause count
6116 // g is graduality :)
6117 //floater_walk(rate,hrate,dstep/100,(zfix)0,10,dmisc16,dmisc17);
6118 3989892 void enemy::floater_walk(int32_t newrate,int32_t newclk,zfix ms,zfix ss,int32_t s,int32_t p, int32_t g)
6119 {
6120 3989892 ++clk2;
6121 3989892 byte over_pit = overpit(this);
6122
6123
4/4
✓ Branch 0 taken 1114794 times.
✓ Branch 1 taken 2875098 times.
✓ Branch 2 taken 1114527 times.
✓ Branch 3 taken 267 times.
3989892 if(dmisc1 && over_pit) p = 0;
6124
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 56213 times.
✓ Branch 2 taken 1570783 times.
✓ Branch 3 taken 2230728 times.
✓ Branch 4 taken 132168 times.
3989892 switch(movestatus)
6125 {
6126 //! This needs a case 4 (landing)....if we want to halt, we move to case 4, and
6127 //! if the conditions prevent it, we jump back to case 2.
6128 case 0: // paused
6129
2/2
✓ Branch 0 taken 54765 times.
✓ Branch 1 taken 1448 times.
56213 if(clk2>=p)
6130 {
6131 1448 movestatus=1;
6132 1448 clk2=0;
6133 1448 }
6134
6135 56213 break;
6136
6137 case 1: // speeding up
6138
1/2
✓ Branch 0 taken 1570783 times.
✗ Branch 1 not taken.
1570783 if (s >= 0)
6139 {
6140
2/2
✓ Branch 0 taken 1559550 times.
✓ Branch 1 taken 11233 times.
1570783 if(clk2<g*s)
6141 {
6142
2/2
✓ Branch 0 taken 1458948 times.
✓ Branch 1 taken 100602 times.
1559550 if(!((clk2-1)%g))
6143 100602 step+=ss;
6144 1559550 }
6145 else
6146 {
6147 11233 movestatus=2;
6148 11233 clk2=0;
6149 }
6150 1570783 }
6151 else
6152 {
6153 if(step < ms)
6154 {
6155 if(!((clk2-1)%g))
6156 {
6157 step+=ss;
6158 if (step >= ms) step = ms;
6159 }
6160 }
6161 else
6162 {
6163 step = ms;
6164 movestatus=2;
6165 clk2=0;
6166 }
6167 }
6168
6169 1570783 break;
6170
6171 case 2: // normal
6172 2230728 step=ms;
6173
6174
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 2230728 times.
✓ Branch 2 taken 477682 times.
✓ Branch 3 taken 1753046 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1753046 times.
✓ Branch 6 taken 1750807 times.
✓ Branch 7 taken 2239 times.
2230728 if(clk2>(dmisc15>0?dmisc15:48) && !(zc_oldrand()%(dmisc14>0?dmisc14:768)))
6175 {
6176
1/2
✓ Branch 0 taken 2239 times.
✗ Branch 1 not taken.
2239 if (s >= 0) step=ss*s;
6177 else step=ms;
6178 2239 movestatus=3;
6179 2239 clk2=0;
6180 2239 }
6181
6182 2230728 break;
6183
6184 case 3: // slowing down
6185
1/2
✓ Branch 0 taken 132168 times.
✗ Branch 1 not taken.
132168 if (s >= 0)
6186 {
6187
2/2
✓ Branch 0 taken 130491 times.
✓ Branch 1 taken 1677 times.
132168 if(clk2<=g*s)
6188 {
6189 { //don't slow down over pits
6190
6191
2/2
✓ Branch 0 taken 267 times.
✓ Branch 1 taken 130224 times.
130491 if(over_pit)
6192 {
6193
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 267 times.
267 if(dmisc1)
6194 {
6195 step=ms;
6196 }
6197 267 }
6198 else //can slow down
6199 {
6200
4/4
✓ Branch 0 taken 8036 times.
✓ Branch 1 taken 122188 times.
✓ Branch 2 taken 7668 times.
✓ Branch 3 taken 368 times.
130224 if(!(clk2%g) && !dmisc1)
6201 7668 step-=ss;
6202 }
6203 }
6204
6205
6206 130491 }
6207 else
6208 {
6209 //if((moveflags&move_can_pitfall)) //don't check pits if the enemy ignores them
6210 //this doesn't help keese, as they have a z of 0.
6211 //they always nee to run this check.
6212 {
6213
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1677 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1677 if(over_pit &&!dmisc1)
6214 {
6215 --clk2; //if over a pit, don't land, and revert clock change
6216 }
6217 else //can land safely
6218 {
6219 1677 movestatus=0;
6220
3/4
✓ Branch 0 taken 1115 times.
✓ Branch 1 taken 562 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1115 times.
1677 if(dmisc1&&!over_pit)
6221 1115 step=0;
6222 1677 clk2=0;
6223 }
6224 }
6225
6226 }
6227 132168 }
6228 else
6229 {
6230 if(step > 0)
6231 {
6232 if(over_pit)
6233 {
6234 if(dmisc1)
6235 {
6236 step=ms;
6237 }
6238 }
6239 else //can slow down
6240 {
6241 if(!(clk2%g))
6242 step-=ss;
6243 }
6244 }
6245 else
6246 {
6247 //if((moveflags&move_can_pitfall)) //don't check pits if the enemy ignores them
6248 //this doesn't help keese, as they have a z of 0.
6249 //they always nee to run this check.
6250 if(over_pit)
6251 {
6252 step+=ss; //if over a pit, don't land, and revert clock change
6253 }
6254 else //can land safely
6255 {
6256 movestatus=0;
6257 step=0;
6258 clk2=0;
6259 }
6260 }
6261 }
6262
6263 132168 break;
6264 }
6265
6266
2/2
✓ Branch 0 taken 2239722 times.
✓ Branch 1 taken 1750170 times.
3989892 variable_walk_8(movestatus==2?newrate:0,homing,newclk,spw_floater);
6267 3989892 }
6268
6269 void enemy::floater_walk(int32_t newrate,int32_t newclk,zfix s)
6270 {
6271 floater_walk(newrate,newclk,s,(zfix)0.125,3,80,32);
6272 }
6273
6274 // Checks if enemy is lined up with Hero. If so, returns direction Hero is
6275 // at as compared to enemy. Returns -1 if not lined up. Range is inclusive.
6276 923646 int32_t enemy::lined_up(int32_t range, bool dir8)
6277 {
6278 923646 int32_t lx = Hero.getX();
6279 923646 int32_t ly = Hero.getY();
6280
6281
2/2
✓ Branch 0 taken 38484 times.
✓ Branch 1 taken 885162 times.
923646 if(abs(lx-int32_t(x))<=range)
6282 {
6283
2/2
✓ Branch 0 taken 16113 times.
✓ Branch 1 taken 22371 times.
38484 if(ly<y)
6284 {
6285 16113 return up;
6286 }
6287
6288 22371 return down;
6289 }
6290
6291
2/2
✓ Branch 0 taken 56299 times.
✓ Branch 1 taken 828863 times.
885162 if(abs(ly-int32_t(y))<=range)
6292 {
6293
2/2
✓ Branch 0 taken 30278 times.
✓ Branch 1 taken 26021 times.
56299 if(lx<x)
6294 {
6295 30278 return left;
6296 }
6297
6298 26021 return right;
6299 }
6300
6301
2/2
✓ Branch 0 taken 159813 times.
✓ Branch 1 taken 669050 times.
828863 if(dir8)
6302 {
6303
2/2
✓ Branch 0 taken 252160 times.
✓ Branch 1 taken 416890 times.
669050 if(abs(lx-x)-abs(ly-y)<=range)
6304 //if(abs(lx-x)-abs(ly-y)<=range && abs(ly-y)-abs(lx-x)<=range) //Fix floating enemies not seeking hero. -Tamamo
6305 {
6306
2/2
✓ Branch 0 taken 105160 times.
✓ Branch 1 taken 147000 times.
252160 if(ly<y)
6307 {
6308
2/2
✓ Branch 0 taken 56622 times.
✓ Branch 1 taken 48538 times.
105160 if(lx<x)
6309 {
6310 56622 return l_up;
6311 }
6312 else
6313 {
6314 48538 return r_up;
6315 }
6316 }
6317 else
6318 {
6319
2/2
✓ Branch 0 taken 76220 times.
✓ Branch 1 taken 70780 times.
147000 if(lx<x)
6320 {
6321 70780 return l_down;
6322 }
6323 else
6324 {
6325 76220 return r_down;
6326 }
6327 }
6328 }
6329 416890 }
6330
6331 576703 return -1;
6332 923646 }
6333
6334 // returns true if Hero is within 'range' pixels of the enemy
6335 27884 bool enemy::HeroInRange(int32_t range)
6336 {
6337 27884 int32_t lx = Hero.getX();
6338 27884 int32_t ly = Hero.getY();
6339
2/2
✓ Branch 0 taken 22775 times.
✓ Branch 1 taken 5109 times.
27884 return abs(lx-int32_t(x))<=range && abs(ly-int32_t(y))<=range;
6340 }
6341
6342 // place the enemy in line with Hero (red wizzrobes)
6343 4858 void enemy::place_on_axis(bool floater, bool solid_ok)
6344 {
6345
6/6
✓ Branch 0 taken 573 times.
✓ Branch 1 taken 4285 times.
✓ Branch 2 taken 4316 times.
✓ Branch 3 taken 542 times.
✓ Branch 4 taken 573 times.
✓ Branch 5 taken 3743 times.
4858 int32_t lx=zc_min(zc_max(int32_t(Hero.getX())&0xF0,32),208);
6346
6/6
✓ Branch 0 taken 437 times.
✓ Branch 1 taken 4421 times.
✓ Branch 2 taken 4082 times.
✓ Branch 3 taken 776 times.
✓ Branch 4 taken 437 times.
✓ Branch 5 taken 3645 times.
4858 int32_t ly=zc_min(zc_max(int32_t(Hero.getY())&0xF0,32),128);
6347 4858 int32_t pos2=zc_oldrand()%23;
6348 4858 int32_t tried=0;
6349 4858 bool last_resort,placed=false;
6350
6351
6352 4858 do
6353 {
6354
2/2
✓ Branch 0 taken 4432 times.
✓ Branch 1 taken 3104 times.
7536 if(pos2<14)
6355 {
6356 4432 x=(pos2<<4)+16;
6357 4432 y=ly;
6358 4432 }
6359 else
6360 {
6361 3104 x=lx;
6362 3104 y=((pos2-14)<<4)+16;
6363 }
6364
6365 // Don't commit to a last resort if position is out of bounds.
6366
6/6
✓ Branch 0 taken 7199 times.
✓ Branch 1 taken 337 times.
✓ Branch 2 taken 6889 times.
✓ Branch 3 taken 310 times.
✓ Branch 4 taken 255 times.
✓ Branch 5 taken 6634 times.
7536 last_resort= !(x<32 || y<32 || x>=224 || y>=144);
6367
6368
4/4
✓ Branch 0 taken 3879 times.
✓ Branch 1 taken 3657 times.
✓ Branch 2 taken 4912 times.
✓ Branch 3 taken 1443 times.
7536 if(abs(lx-int32_t(x))>16 || abs(ly-int32_t(y))>16)
6369 {
6370 // Red Wizzrobes should be able to appear on water, but not other
6371 // solid combos; however, they could appear on solid combos in 2.10,
6372 // and some quests depend on that.
6373
4/4
✓ Branch 0 taken 2341 times.
✓ Branch 1 taken 6228 times.
✓ Branch 2 taken 1370 times.
✓ Branch 3 taken 4858 times.
8569 if((solid_ok || !m_walkflag(x,y,floater ? spw_water : spw_door, dir))
6374 8569 && !flyerblocked(x,y,floater ? spw_floater : spw_door))
6375 4858 placed=true;
6376 8569 }
6377
6378
3/6
✓ Branch 0 taken 2678 times.
✓ Branch 1 taken 4662 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2678 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7340 if(!placed && tried>=22 && last_resort)
6379 {
6380 placed=true;
6381 }
6382
6383 7340 ++tried;
6384 7340 pos2=(pos2+3)%23;
6385
2/2
✓ Branch 0 taken 2678 times.
✓ Branch 1 taken 4662 times.
7340 }
6386 7340 while(!placed);
6387
6388
2/2
✓ Branch 0 taken 2872 times.
✓ Branch 1 taken 1790 times.
4662 if(y==ly)
6389 2872 dir=(x<lx)?right:left;
6390 else
6391 1790 dir=(y<ly)?down:up;
6392
6393 4662 clk2=tried;
6394 4662 }
6395
6396 20213685 int32_t enemy::n_frame_n_dir(int32_t frames, int32_t ndir, int32_t f4)
6397 {
6398 20213685 int32_t t = o_tile;
6399 20213685 int32_t b = o_tile;
6400
6401 // Darknuts, but also Wizzrobes and Wallmasters
6402
3/4
✓ Branch 0 taken 8353120 times.
✓ Branch 1 taken 10837883 times.
✓ Branch 2 taken 1022682 times.
✗ Branch 3 not taken.
20213685 switch(family)
6403 {
6404 case eeWALK:
6405
5/6
✓ Branch 0 taken 505407 times.
✓ Branch 1 taken 10332476 times.
✓ Branch 2 taken 367468 times.
✓ Branch 3 taken 137939 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 367468 times.
10837883 if(dmisc9==e9tPOLSVOICE && clk2>=0 && do_animation)
6406 {
6407 367468 tile=s_tile;
6408 367468 t=s_tile;
6409 367468 b=s_tile;
6410 367468 }
6411
6412 10837883 break;
6413
6414 case eeTRAP:
6415
4/6
✓ Branch 0 taken 193566 times.
✓ Branch 1 taken 829116 times.
✓ Branch 2 taken 193566 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 193566 times.
1022682 if(dummy_int[1] && guysbuf[id].flags & guy_trp2 && do_animation) // Just to make sure
6416 {
6417 193566 tile=s_tile;
6418 193566 t=s_tile;
6419 193566 b=s_tile;
6420 193566 }
6421
6422 1022682 break;
6423
6424 case eeSPINTILE:
6425 if(misc>=96 && do_animation)
6426 {
6427 tile=o_tile+frames*ndir;
6428 t=tile;
6429 }
6430
6431 break;
6432 }
6433
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20213685 times.
20213685 if ( do_animation )
6434 {
6435
4/6
✓ Branch 0 taken 197042 times.
✓ Branch 1 taken 20016643 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 267131 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 19749512 times.
20213685 if(ndir!=0) switch(frames)
6436 {
6437 case 2:
6438 267131 tiledir_small(dir,ndir==4);
6439 267131 break;
6440
6441 case 3:
6442 tiledir_three(dir);
6443 break;
6444
6445 case 4:
6446 19749512 tiledir(dir,ndir==4);
6447 19749512 break;
6448 20016643 }
6449
6450
2/2
✓ Branch 0 taken 10837883 times.
✓ Branch 1 taken 9375802 times.
20213685 if(family==eeWALK)
6451
6/6
✓ Branch 0 taken 10776874 times.
✓ Branch 1 taken 61009 times.
✓ Branch 2 taken 8177902 times.
✓ Branch 3 taken 2659981 times.
✓ Branch 4 taken 2644258 times.
✓ Branch 5 taken 15723 times.
10837883 tile=zc_min(tile+f4, t+frames*(zc_max(dir, 0)+1)-1);
6452 else
6453 9375802 tile+=f4;
6454 20213685 }
6455 20213685 return b;
6456 }
6457
6458 void enemy::tiledir_three(int32_t ndir)
6459 {
6460 if ( !do_animation ) return;
6461 flip=0;
6462
6463 switch(ndir)
6464 {
6465 case right:
6466 tile+=3;
6467 [[fallthrough]];
6468
6469 case left:
6470 tile+=3;
6471 [[fallthrough]];
6472
6473 case down:
6474 tile+=3;
6475 [[fallthrough]];
6476
6477 case up:
6478 break;
6479 }
6480 }
6481
6482 267131 void enemy::tiledir_small(int32_t ndir, bool fourdir)
6483 {
6484
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 267131 times.
267131 if ( !do_animation ) return;
6485 267131 flip=0;
6486
6487
8/9
✓ Branch 0 taken 53829 times.
✓ Branch 1 taken 54679 times.
✓ Branch 2 taken 67727 times.
✓ Branch 3 taken 71182 times.
✓ Branch 4 taken 5706 times.
✓ Branch 5 taken 5154 times.
✓ Branch 6 taken 4872 times.
✓ Branch 7 taken 3982 times.
✗ Branch 8 not taken.
267131 switch(ndir)
6488 {
6489 case 8:
6490 case up:
6491 53829 break;
6492
6493 case 12:
6494 case down:
6495 54679 tile+=2;
6496 54679 break;
6497
6498 case 14:
6499 case left:
6500 67727 tile+=4;
6501 67727 break;
6502
6503 case 10:
6504 case right:
6505 71182 tile+=6;
6506 71182 break;
6507
6508 case 9:
6509 case r_up:
6510
1/2
✓ Branch 0 taken 5706 times.
✗ Branch 1 not taken.
5706 if(fourdir)
6511 5706 break;
6512
6513 tile+=10;
6514 break;
6515
6516 case 11:
6517 case r_down:
6518
1/2
✓ Branch 0 taken 5154 times.
✗ Branch 1 not taken.
5154 if(fourdir)
6519 5154 tile+=2;
6520 else
6521 tile+=14;
6522
6523 5154 break;
6524
6525 case 13:
6526 case l_down:
6527
1/2
✓ Branch 0 taken 4872 times.
✗ Branch 1 not taken.
4872 if(fourdir)
6528 4872 tile+=2;
6529 else
6530 tile+=12;
6531
6532 4872 break;
6533
6534 case 15:
6535 case l_up:
6536
1/2
✓ Branch 0 taken 3982 times.
✗ Branch 1 not taken.
3982 if(fourdir)
6537 3982 break;
6538
6539 tile+=8;
6540 break;
6541
6542 default:
6543 //dir=(zc_oldrand()*100)%8;
6544 //tiledir_small(dir);
6545 // flip=zc_oldrand()&3;
6546 // tile=(zc_oldrand()*100000)%NEWMAXTILES;
6547 break;
6548 }
6549 267131 }
6550
6551 23069632 void enemy::tiledir(int32_t ndir, bool fourdir)
6552 {
6553
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23069632 times.
23069632 if ( !do_animation ) return;
6554 23069632 flip=0;
6555
6556
9/9
✓ Branch 0 taken 4483892 times.
✓ Branch 1 taken 4141765 times.
✓ Branch 2 taken 5412757 times.
✓ Branch 3 taken 5175571 times.
✓ Branch 4 taken 825768 times.
✓ Branch 5 taken 1018734 times.
✓ Branch 6 taken 1099241 times.
✓ Branch 7 taken 845055 times.
✓ Branch 8 taken 66849 times.
23069632 switch(ndir)
6557 {
6558 case 8:
6559 case up:
6560 4483892 break;
6561
6562 case 12:
6563 case down:
6564 4141765 tile+=4;
6565 4141765 break;
6566
6567 case 14:
6568 case left:
6569 5412757 tile+=8;
6570 5412757 break;
6571
6572 case 10:
6573 case right:
6574 5175571 tile+=12;
6575 5175571 break;
6576
6577 case 9:
6578 case r_up:
6579
2/2
✓ Branch 0 taken 88653 times.
✓ Branch 1 taken 737115 times.
825768 if(fourdir)
6580 88653 break;
6581 else
6582 737115 tile+=24;
6583
6584 737115 break;
6585
6586 case 11:
6587 case r_down:
6588
2/2
✓ Branch 0 taken 101949 times.
✓ Branch 1 taken 916785 times.
1018734 if(fourdir)
6589 101949 tile+=4;
6590 else
6591 916785 tile+=32;
6592
6593 1018734 break;
6594
6595 case 13:
6596 case l_down:
6597
2/2
✓ Branch 0 taken 105945 times.
✓ Branch 1 taken 993296 times.
1099241 if(fourdir)
6598 105945 tile+=4;
6599 else
6600 993296 tile+=28;
6601
6602 1099241 break;
6603
6604 case 15:
6605 case l_up:
6606
2/2
✓ Branch 0 taken 82760 times.
✓ Branch 1 taken 762295 times.
845055 if(fourdir)
6607 82760 break;
6608 else
6609 762295 tile+=20;
6610
6611 762295 break;
6612
6613 default:
6614 //dir=(zc_oldrand()*100)%8;
6615 //tiledir(dir);
6616 // flip=zc_oldrand()&3;
6617 // tile=(zc_oldrand()*100000)%NEWMAXTILES;
6618 66849 break;
6619 }
6620 23069632 }
6621
6622 3868 void enemy::tiledir_big(int32_t ndir, bool fourdir)
6623 {
6624
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if ( !do_animation ) return;
6625 3868 flip=0;
6626
6627
7/9
✓ Branch 0 taken 297 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 195 times.
✓ Branch 3 taken 179 times.
✓ Branch 4 taken 306 times.
✓ Branch 5 taken 1235 times.
✓ Branch 6 taken 1324 times.
✓ Branch 7 taken 332 times.
✗ Branch 8 not taken.
3868 switch(ndir)
6628 {
6629 case 8:
6630 case up:
6631 297 break;
6632
6633 case 12:
6634 case down:
6635 tile+=8;
6636 break;
6637
6638 case 14:
6639 case left:
6640 195 tile+=40;
6641 195 break;
6642
6643 case 10:
6644 case right:
6645 179 tile+=48;
6646 179 break;
6647
6648 case 9:
6649 case r_up:
6650
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 306 times.
306 if(fourdir)
6651 break;
6652
6653 306 tile+=88;
6654 306 break;
6655
6656 case 11:
6657 case r_down:
6658
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1235 times.
1235 if(fourdir)
6659 tile+=8;
6660 else
6661 1235 tile+=128;
6662
6663 1235 break;
6664
6665 case 13:
6666 case l_down:
6667
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1324 times.
1324 if(fourdir)
6668 tile+=8;
6669 else
6670 1324 tile+=120;
6671
6672 1324 break;
6673
6674 case 15:
6675 case l_up:
6676
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 332 times.
332 if(fourdir)
6677 break;
6678
6679 332 tile+=80;
6680 332 break;
6681
6682 default:
6683 //dir=(zc_oldrand()*100)%8;
6684 //tiledir_big(dir);
6685 // flip=zc_oldrand()&3;
6686 // tile=(zc_oldrand()*100000)%NEWMAXTILES;
6687 break;
6688 }
6689 3868 }
6690
6691 39899525 void enemy::update_enemy_frame()
6692 {
6693
4/4
✓ Branch 0 taken 39897219 times.
✓ Branch 1 taken 2306 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 39897212 times.
39899525 if(fallclk||drownclk) return;
6694
1/2
✓ Branch 0 taken 39897212 times.
✗ Branch 1 not taken.
39897212 if (!do_animation)
6695 return;
6696
6697
4/4
✓ Branch 0 taken 1476456 times.
✓ Branch 1 taken 38420756 times.
✓ Branch 2 taken 1474449 times.
✓ Branch 3 taken 2007 times.
39897212 if (get_qr(qr_OLD_TILE_INITIALIZATION) || tile == 0) tile = o_tile; //tile was initialized here before. It needs to be initialized here as well.
6698
6699
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
39897212 if(get_qr(qr_ANONE_NOANIM)
6700
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 39897212 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
39897212 && anim == aNONE && family != eeGUY)
6701 return;
6702
2/2
✓ Branch 0 taken 371376 times.
✓ Branch 1 taken 39525836 times.
39897212 int32_t newfrate = zc_max(frate,4);
6703 39897212 int32_t f4=abs(clk/(newfrate/4)); // casts clk to [0,1,2,3]
6704 39897212 int32_t f2=abs(clk/(newfrate/2)); // casts clk to [0,1]
6705
2/2
✓ Branch 0 taken 29906117 times.
✓ Branch 1 taken 9991095 times.
39897212 int32_t fx = get_qr(qr_NEWENEMYTILES) ? f4 : f2;
6706 39897212 tile = o_tile;
6707 39897212 int32_t basetile = o_tile;
6708 39897212 int32_t tilerows = 1; // How many rows of tiles? The Extend code needs to know.
6709 39897212 bool ignore_extend = false;
6710
35/40
✓ Branch 0 taken 220021 times.
✓ Branch 1 taken 8628 times.
✓ Branch 2 taken 201747 times.
✓ Branch 3 taken 1755010 times.
✓ Branch 4 taken 363745 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 140514 times.
✓ Branch 7 taken 366633 times.
✓ Branch 8 taken 836734 times.
✓ Branch 9 taken 3868 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 4987111 times.
✓ Branch 12 taken 69324 times.
✓ Branch 13 taken 53456 times.
✓ Branch 14 taken 38833 times.
✓ Branch 15 taken 455374 times.
✓ Branch 16 taken 1519575 times.
✓ Branch 17 taken 197042 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 128880 times.
✓ Branch 20 taken 221637 times.
✓ Branch 21 taken 686882 times.
✓ Branch 22 taken 1690654 times.
✓ Branch 23 taken 1133827 times.
✗ Branch 24 not taken.
✓ Branch 25 taken 267131 times.
✓ Branch 26 taken 4117708 times.
✓ Branch 27 taken 7475916 times.
✗ Branch 28 not taken.
✓ Branch 29 taken 582791 times.
✓ Branch 30 taken 1178979 times.
✓ Branch 31 taken 880176 times.
✓ Branch 32 taken 218668 times.
✓ Branch 33 taken 1812060 times.
✓ Branch 34 taken 133344 times.
✓ Branch 35 taken 1433 times.
✓ Branch 36 taken 6953976 times.
✓ Branch 37 taken 747030 times.
✓ Branch 38 taken 276997 times.
✓ Branch 39 taken 171508 times.
39897212 switch(anim)
6711 {
6712
6713 case aDONGO:
6714 {
6715 69324 int32_t fr = stunclk>0 ? 16 : 8;
6716
6717
6/6
✓ Branch 0 taken 67426 times.
✓ Branch 1 taken 1898 times.
✓ Branch 2 taken 6720 times.
✓ Branch 3 taken 60706 times.
✓ Branch 4 taken 2240 times.
✓ Branch 5 taken 4480 times.
69324 if(!dying && clk2>0 && clk2<=64)
6718 {
6719 // bloated
6720
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 960 times.
✓ Branch 2 taken 960 times.
✓ Branch 3 taken 1664 times.
✓ Branch 4 taken 896 times.
4480 switch(dir)
6721 {
6722 case up:
6723 960 tile+=9;
6724 960 flip=0;
6725 960 xofs=0;
6726 960 dummy_int[1]=0; //no additional tiles
6727 960 break;
6728
6729 case down:
6730 960 tile+=7;
6731 960 flip=0;
6732 960 xofs=0;
6733 960 dummy_int[1]=0; //no additional tiles
6734 960 break;
6735
6736 case left:
6737 1664 flip=1;
6738 1664 tile+=4;
6739 1664 xofs=16;
6740 1664 dummy_int[1]=1; //second tile is next tile
6741 1664 break;
6742
6743 case right:
6744 896 flip=0;
6745 896 tile+=5;
6746 896 xofs=16;
6747 896 dummy_int[1]=-1; //second tile is previous tile
6748 896 break;
6749 }
6750 4480 }
6751
4/4
✓ Branch 0 taken 1898 times.
✓ Branch 1 taken 62946 times.
✓ Branch 2 taken 781 times.
✓ Branch 3 taken 1117 times.
64844 else if(!dying || clk2>19)
6752 {
6753 // normal
6754
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 13652 times.
✓ Branch 2 taken 15374 times.
✓ Branch 3 taken 19615 times.
✓ Branch 4 taken 15086 times.
63727 switch(dir)
6755 {
6756 case up:
6757 13652 tile+=8;
6758 13652 flip=(clk&fr)?1:0;
6759 13652 xofs=0;
6760 13652 dummy_int[1]=0; //no additional tiles
6761 13652 break;
6762
6763 case down:
6764 15374 tile+=6;
6765 15374 flip=(clk&fr)?1:0;
6766 15374 xofs=0;
6767 15374 dummy_int[1]=0; //no additional tiles
6768 15374 break;
6769
6770 case left:
6771 19615 flip=1;
6772 19615 tile+=(clk&fr)?2:0;
6773 19615 xofs=16;
6774 19615 dummy_int[1]=1; //second tile is next tile
6775 19615 break;
6776
6777 case right:
6778 15086 flip=0;
6779 15086 tile+=(clk&fr)?3:1;
6780 15086 xofs=16;
6781 15086 dummy_int[1]=-1; //second tile is next tile
6782 15086 break;
6783 }
6784 63727 }
6785 }
6786 69324 break;
6787
6788 case aNEWDONGO:
6789 {
6790 53456 int32_t fr4=0;
6791
6792
6/6
✓ Branch 0 taken 51564 times.
✓ Branch 1 taken 1892 times.
✓ Branch 2 taken 4128 times.
✓ Branch 3 taken 47436 times.
✓ Branch 4 taken 1376 times.
✓ Branch 5 taken 2752 times.
53456 if(!dying && clk2>0 && clk2<=64)
6793 {
6794 // bloated
6795
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2752 times.
2752 if(clk2>=0)
6796 {
6797 2752 fr4=3;
6798 2752 }
6799
6800
2/2
✓ Branch 0 taken 645 times.
✓ Branch 1 taken 2107 times.
2752 if(clk2>=16)
6801 {
6802 2107 fr4=2;
6803 2107 }
6804
6805
2/2
✓ Branch 0 taken 1333 times.
✓ Branch 1 taken 1419 times.
2752 if(clk2>=32)
6806 {
6807 1419 fr4=1;
6808 1419 }
6809
6810
2/2
✓ Branch 0 taken 2021 times.
✓ Branch 1 taken 731 times.
2752 if(clk2>=48)
6811 {
6812 731 fr4=0;
6813 731 }
6814
6815
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 256 times.
✓ Branch 2 taken 576 times.
✓ Branch 3 taken 704 times.
✓ Branch 4 taken 1216 times.
2752 switch(dir)
6816 {
6817 case up:
6818 256 xofs=0;
6819 256 tile+=8+fr4;
6820 256 dummy_int[1]=0; //no additional tiles
6821 256 break;
6822
6823 case down:
6824 576 xofs=0;
6825 576 tile+=12+fr4;
6826 576 dummy_int[1]=0; //no additional tiles
6827 576 break;
6828
6829 case left:
6830 704 tile+=29+(2*fr4);
6831 704 xofs=16;
6832 704 dummy_int[1]=-1; //second tile is previous tile
6833 704 break;
6834
6835 case right:
6836 1216 tile+=49+(2*fr4);
6837 1216 xofs=16;
6838 1216 dummy_int[1]=-1; //second tile is previous tile
6839 1216 break;
6840 }
6841 2752 }
6842
4/4
✓ Branch 0 taken 1892 times.
✓ Branch 1 taken 48812 times.
✓ Branch 2 taken 994 times.
✓ Branch 3 taken 898 times.
50704 else if(!dying || clk2>19)
6843 {
6844 // normal
6845
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 9234 times.
✓ Branch 2 taken 9871 times.
✓ Branch 3 taken 15025 times.
✓ Branch 4 taken 15676 times.
49806 switch(dir)
6846 {
6847 case up:
6848 9234 xofs=0;
6849 9234 tile+=((clk&12)>>2);
6850 9234 dummy_int[1]=0; //no additional tiles
6851 9234 break;
6852
6853 case down:
6854 9871 xofs=0;
6855 9871 tile+=4+((clk&12)>>2);
6856 9871 dummy_int[1]=0; //no additional tiles
6857 9871 break;
6858
6859 case left:
6860 15025 tile+=21+((clk&12)>>1);
6861 15025 xofs=16;
6862 15025 dummy_int[1]=-1; //second tile is previous tile
6863 15025 break;
6864
6865 case right:
6866 15676 flip=0;
6867 15676 tile+=41+((clk&12)>>1);
6868 15676 xofs=16;
6869 15676 dummy_int[1]=-1; //second tile is previous tile
6870 15676 break;
6871 }
6872 49806 }
6873 }
6874 53456 break;
6875
6876 case aDONGOBS:
6877 {
6878 38833 int32_t fr4=0;
6879
6880
6/6
✓ Branch 0 taken 37675 times.
✓ Branch 1 taken 1158 times.
✓ Branch 2 taken 4032 times.
✓ Branch 3 taken 33643 times.
✓ Branch 4 taken 1344 times.
✓ Branch 5 taken 2688 times.
38833 if(!dying && clk2>0 && clk2<=64)
6881 {
6882 // bloated
6883
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2688 times.
2688 if(clk2>=0)
6884 {
6885 2688 fr4=3;
6886 2688 }
6887
6888
2/2
✓ Branch 0 taken 630 times.
✓ Branch 1 taken 2058 times.
2688 if(clk2>=16)
6889 {
6890 2058 fr4=2;
6891 2058 }
6892
6893
2/2
✓ Branch 0 taken 1302 times.
✓ Branch 1 taken 1386 times.
2688 if(clk2>=32)
6894 {
6895 1386 fr4=1;
6896 1386 }
6897
6898
2/2
✓ Branch 0 taken 1974 times.
✓ Branch 1 taken 714 times.
2688 if(clk2>=48)
6899 {
6900 714 fr4=0;
6901 714 }
6902
6903
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 256 times.
✓ Branch 2 taken 384 times.
✓ Branch 3 taken 1024 times.
✓ Branch 4 taken 1024 times.
2688 switch(dir)
6904 {
6905 case up:
6906 256 tile+=28+fr4;
6907 256 yofs+=8;
6908 256 dummy_int[1]=-20; //second tile change
6909 256 dummy_int[2]=0; //new xofs change
6910 256 dummy_int[3]=-16; //new xofs change
6911 256 break;
6912
6913 case down:
6914 384 tile+=12+fr4;
6915 384 yofs-=8;
6916 384 dummy_int[1]=20; //second tile change
6917 384 dummy_int[2]=0; //new xofs change
6918 384 dummy_int[3]=16; //new xofs change
6919 384 break;
6920
6921 case left:
6922 1024 tile+=49+(2*fr4);
6923 1024 xofs+=8;
6924 1024 dummy_int[1]=-1; //second tile change
6925 1024 dummy_int[2]=-16; //new xofs change
6926 1024 dummy_int[3]=0; //new xofs change
6927 1024 break;
6928
6929 case right:
6930 1024 tile+=69+(2*fr4);
6931 1024 xofs+=8;
6932 1024 dummy_int[1]=-1; //second tile change
6933 1024 dummy_int[2]=-16; //new xofs change
6934 1024 dummy_int[3]=0; //new xofs change
6935 1024 break;
6936 }
6937 2688 }
6938
4/4
✓ Branch 0 taken 1158 times.
✓ Branch 1 taken 34987 times.
✓ Branch 2 taken 497 times.
✓ Branch 3 taken 661 times.
36145 else if(!dying || clk2>19)
6939 {
6940 // normal
6941
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 7136 times.
✓ Branch 2 taken 6672 times.
✓ Branch 3 taken 11075 times.
✓ Branch 4 taken 10601 times.
35484 switch(dir)
6942 {
6943 case up:
6944 7136 tile+=20+((clk&24)>>3);
6945 7136 yofs+=8;
6946 7136 dummy_int[1]=-20; //second tile change
6947 7136 dummy_int[2]=0; //new xofs change
6948 7136 dummy_int[3]=-16; //new xofs change
6949 7136 break;
6950
6951 case down:
6952 6672 tile+=4+((clk&24)>>3);
6953 6672 yofs-=8;
6954 6672 dummy_int[1]=20; //second tile change
6955 6672 dummy_int[2]=0; //new xofs change
6956 6672 dummy_int[3]=16; //new xofs change
6957 6672 break;
6958
6959 case left:
6960 11075 xofs=-8;
6961 11075 tile+=40+((clk&24)>>2);
6962 11075 dummy_int[1]=1; //second tile change
6963 11075 dummy_int[2]=16; //new xofs change
6964 11075 dummy_int[3]=0; //new xofs change
6965 11075 break;
6966
6967 case right:
6968 10601 tile+=60+((clk&24)>>2);
6969 10601 xofs=-8;
6970 10601 dummy_int[1]=1; //second tile change
6971 10601 dummy_int[2]=16; //new xofs change
6972 10601 dummy_int[3]=0; //new xofs change
6973 10601 break;
6974 }
6975 35484 }
6976 }
6977 38833 break;
6978
6979 case aWIZZ:
6980 {
6981 // if(d->misc1)
6982
2/2
✓ Branch 0 taken 182184 times.
✓ Branch 1 taken 273190 times.
455374 if(dmisc1)
6983 {
6984
2/2
✓ Branch 0 taken 91057 times.
✓ Branch 1 taken 91127 times.
182184 if(clk&8)
6985 {
6986 91127 ++tile;
6987 91127 }
6988 182184 }
6989 else
6990 {
6991
2/2
✓ Branch 0 taken 136701 times.
✓ Branch 1 taken 136489 times.
273190 if(frame&4)
6992 {
6993 136489 ++tile;
6994 136489 }
6995 }
6996
6997
4/4
✓ Branch 0 taken 76094 times.
✓ Branch 1 taken 157108 times.
✓ Branch 2 taken 145581 times.
✓ Branch 3 taken 76591 times.
455374 switch(dir)
6998 {
6999 case 9:
7000 case 15:
7001 case up:
7002 76094 tile+=2;
7003 76094 break;
7004
7005 case down:
7006 76591 break;
7007
7008 case 13:
7009 case left:
7010 157108 flip=1;
7011 157108 break;
7012
7013 default:
7014 145581 flip=0;
7015 145581 break;
7016 }
7017 }
7018 455374 break;
7019
7020 case aNEWWIZZ:
7021 {
7022 1519575 tiledir(dir,true);
7023
7024 // if(d->misc1) //walking wizzrobe
7025
2/2
✓ Branch 0 taken 742424 times.
✓ Branch 1 taken 777151 times.
1519575 if(dmisc1) //walking wizzrobe
7026 {
7027
2/2
✓ Branch 0 taken 373321 times.
✓ Branch 1 taken 369103 times.
742424 if(clk&8)
7028 {
7029 369103 tile+=2;
7030 369103 }
7031
7032
2/2
✓ Branch 0 taken 372085 times.
✓ Branch 1 taken 370339 times.
742424 if(clk&4)
7033 {
7034 370339 tile+=1;
7035 370339 }
7036
7037
2/4
✓ Branch 0 taken 742424 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 742424 times.
742424 if(!(dummy_bool[1]||dummy_bool[2])) //should never be charging or firing for these wizzrobes
7038 {
7039
2/2
✓ Branch 0 taken 663262 times.
✓ Branch 1 taken 79162 times.
742424 if(dummy_int[1]>0)
7040 {
7041 79162 tile+=40;
7042 79162 }
7043 742424 }
7044 742424 }
7045 else
7046 {
7047
4/4
✓ Branch 0 taken 710492 times.
✓ Branch 1 taken 66659 times.
✓ Branch 2 taken 167559 times.
✓ Branch 3 taken 542933 times.
777151 if(dummy_bool[1]||dummy_bool[2])
7048 {
7049 234218 tile+=20;
7050
7051
2/2
✓ Branch 0 taken 66650 times.
✓ Branch 1 taken 167568 times.
234218 if(dummy_bool[2])
7052 {
7053 167568 tile+=20;
7054 167568 }
7055 234218 }
7056
7057 777151 tile+=((frame>>1)&3);
7058 }
7059 }
7060 1519575 break;
7061
7062 case a3FRM:
7063 {
7064
2/2
✓ Branch 0 taken 46675 times.
✓ Branch 1 taken 150367 times.
197042 basetile = n_frame_n_dir(3, 0, (f4==3) ? 1 : f4);
7065 }
7066 197042 break;
7067
7068 case a3FRM4DIR:
7069 {
7070 basetile = n_frame_n_dir(3, 4, (f4==3) ? 1 : f4);
7071 }
7072 break;
7073
7074 case aVIRE:
7075 {
7076
2/2
✓ Branch 0 taken 99588 times.
✓ Branch 1 taken 29292 times.
128880 if(dir==up)
7077 {
7078 29292 tile+=2;
7079 29292 }
7080
7081 128880 tile+=fx;
7082 }
7083 128880 break;
7084
7085 case aROPE:
7086 {
7087 220021 tile+=(1-fx);
7088 220021 flip = dir==left ? 1:0;
7089 }
7090 220021 break;
7091
7092 case aZORA:
7093 {
7094 int32_t dl;
7095
7096
2/2
✓ Branch 0 taken 46739 times.
✓ Branch 1 taken 174898 times.
221637 if(clk<36)
7097 {
7098 46739 dl=clk+5;
7099 46739 goto waves2;
7100 }
7101
7102
2/2
✓ Branch 0 taken 82440 times.
✓ Branch 1 taken 92458 times.
174898 if(clk<36+66)
7103
2/2
✓ Branch 0 taken 50715 times.
✓ Branch 1 taken 31725 times.
82440 tile=(dir==up)?o_tile+1:o_tile;
7104 else
7105 {
7106 92458 dl=clk-36-66;
7107 waves2:
7108 139197 tile=((dl/11)&1)+s_tile;
7109 139197 basetile = s_tile;
7110 }
7111 }
7112 221637 break;
7113
7114 case aNEWZORA:
7115 {
7116 686882 f4=(clk/16)%4;
7117
7118 686882 tiledir(dir,true);
7119 int32_t dl;
7120
7121
4/4
✓ Branch 0 taken 485838 times.
✓ Branch 1 taken 201044 times.
✓ Branch 2 taken 249250 times.
✓ Branch 3 taken 236588 times.
686882 if((clk>35)&&(clk<36+67)) //surfaced
7122 {
7123
4/4
✓ Branch 0 taken 202239 times.
✓ Branch 1 taken 34349 times.
✓ Branch 2 taken 29164 times.
✓ Branch 3 taken 173075 times.
236588 if((clk>=(35+10))&&(clk<(38+56))) //mouth open
7124 {
7125 173075 tile+=80;
7126 173075 } //mouth closed
7127 else
7128 {
7129 63513 tile+=40;
7130 }
7131
7132 236588 tile+=f4;
7133 236588 }
7134 else
7135 {
7136
2/2
✓ Branch 0 taken 201044 times.
✓ Branch 1 taken 249250 times.
450294 if(clk<36)
7137 {
7138 201044 dl=clk+5;
7139 201044 }
7140 else
7141 {
7142 249250 dl=clk-36-66;
7143 }
7144
7145 450294 tile+=((dl/5)&3);
7146 }
7147 }
7148 686882 break;
7149
7150 case a4FRM4EYE:
7151 case a2FRM4EYE:
7152 case a4FRM8EYE:
7153 case a4FRM8EYEB: //big version
7154 case a4FRM4EYEB:
7155 {
7156 836734 tilerows = 2;
7157
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 836734 times.
836734 int fakex = x + 8*(zc_max(1,txsz)-1);
7158
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 836734 times.
836734 int fakey = y + 8*(zc_max(1,tysz)-1);
7159 double _MSVC2022_tmp1, _MSVC2022_tmp2;
7160 836734 double ddir=atan2_MSVC2022_FIX(double(fakey-(Hero.y)),double(Hero.x-fakex));
7161 836734 int32_t lookat=zc_oldrand()&15;
7162
7163
4/4
✓ Branch 0 taken 272091 times.
✓ Branch 1 taken 564643 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 210774 times.
836734 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
7164 {
7165 210774 lookat=l_down;
7166 210774 }
7167
4/4
✓ Branch 0 taken 288167 times.
✓ Branch 1 taken 337793 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 226850 times.
625960 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
7168 {
7169 226850 lookat=down;
7170 226850 }
7171
4/4
✓ Branch 0 taken 170154 times.
✓ Branch 1 taken 228956 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 108837 times.
399110 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
7172 {
7173 108837 lookat=r_down;
7174 108837 }
7175
4/4
✓ Branch 0 taken 131712 times.
✓ Branch 1 taken 158561 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 70395 times.
290273 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
7176 {
7177 70395 lookat=right;
7178 70395 }
7179
4/4
✓ Branch 0 taken 96384 times.
✓ Branch 1 taken 123494 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 35067 times.
219878 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
7180 {
7181 35067 lookat=r_up;
7182 35067 }
7183
4/4
✓ Branch 0 taken 86753 times.
✓ Branch 1 taken 98058 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 25436 times.
184811 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
7184 {
7185 25436 lookat=up;
7186 25436 }
7187
4/4
✓ Branch 0 taken 98120 times.
✓ Branch 1 taken 61255 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 36803 times.
159375 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
7188 {
7189 36803 lookat=l_up;
7190 36803 }
7191 else
7192 {
7193 122572 lookat=left;
7194 }
7195
7196 836734 int32_t dir2 = dir;
7197 836734 dir = lookat;
7198
3/6
✓ Branch 0 taken 836734 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 836734 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 836734 times.
836734 if (anim != a4FRM8EYEB && anim != a4FRM4EYEB) basetile = n_frame_n_dir(anim==a2FRM4EYE ? 2:4, anim==a4FRM8EYE ? 8 : 4, anim==a2FRM4EYE ? (f2&1):f4);
7199 else
7200 {
7201 tiledir_big(dir,(anim == a4FRM4EYEB));
7202 tile+=2*f4;
7203 ignore_extend = true;
7204 }
7205 836734 dir = dir2;
7206 }
7207 836734 break;
7208
7209 case aFLIP:
7210 {
7211 1690654 flip = f2&1;
7212 }
7213 1690654 break;
7214
7215 case a2FRM:
7216 {
7217 1133827 tile += (1-f2);
7218 }
7219 1133827 break;
7220
7221 case a2FRMB:
7222 {
7223 tile+= 2*(1-f2);
7224 ignore_extend = true;
7225 }
7226 break;
7227
7228 case a2FRM4DIR:
7229 {
7230 267131 basetile = n_frame_n_dir(2, 4, f2&1);
7231 }
7232 267131 break;
7233
7234 case a4FRM4DIRF:
7235 {
7236 4117708 basetile = n_frame_n_dir(4,4,f4);
7237
7238
2/2
✓ Branch 0 taken 2717716 times.
✓ Branch 1 taken 1399992 times.
4117708 if(clk2>0) //stopped to fire
7239 {
7240 1399992 tile+=20;
7241
7242
2/2
✓ Branch 0 taken 697526 times.
✓ Branch 1 taken 702466 times.
1399992 if(clk2<17) //firing
7243 {
7244 702466 tile+=20;
7245 702466 }
7246 1399992 }
7247 }
7248 4117708 break;
7249
7250 case a4FRM4DIR:
7251 {
7252 7475916 basetile = n_frame_n_dir(4,4,f4);
7253 }
7254 7475916 break;
7255
7256 case a4FRM8DIRF:
7257 {
7258 tilerows = 2;
7259 basetile = n_frame_n_dir(4,8,f4);
7260
7261 if(clk2>0) //stopped to fire
7262 {
7263 tile+=40;
7264
7265 if(clk2<17) //firing
7266 {
7267 tile+=40;
7268 }
7269 }
7270 }
7271 break;
7272
7273 case a4FRM8DIRB:
7274 case a4FRM8DIRFB:
7275 {
7276 3868 tilerows = 2;
7277 3868 tiledir_big(dir,false);
7278 3868 tile+=2*f4;
7279
3/4
✓ Branch 0 taken 3866 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 3866 times.
✗ Branch 3 not taken.
3868 if(clk2>0 && anim == a4FRM8DIRFB) //stopped to fire
7280 {
7281 tile+=80;
7282
7283 if(clk2<17) //firing
7284 {
7285 tile+=80;
7286 }
7287 }
7288 3868 ignore_extend = true;
7289 }
7290 3868 break;
7291
7292 case a4FRM4DIRB:
7293 case a4FRM4DIRFB:
7294 {
7295 tilerows = 2;
7296 tiledir_big(dir,true);
7297 tile+=2*f4;
7298 if(clk2>0 && anim == a4FRM4DIRFB) //stopped to fire
7299 {
7300 tile+=40;
7301
7302 if(clk2<17) //firing
7303 {
7304 tile+=40;
7305 }
7306 }
7307 ignore_extend = true;
7308 }
7309 break;
7310
7311 case aOCTO:
7312 {
7313
5/5
✓ Branch 0 taken 4152 times.
✓ Branch 1 taken 122459 times.
✓ Branch 2 taken 133448 times.
✓ Branch 3 taken 165605 times.
✓ Branch 4 taken 157127 times.
582791 switch(dir)
7314 {
7315 case up:
7316 122459 flip = 2;
7317 122459 break;
7318
7319 case down:
7320 133448 flip = 0;
7321 133448 break;
7322
7323 case left:
7324 165605 flip = 0;
7325 165605 tile += 2;
7326 165605 break;
7327
7328 case right:
7329 157127 flip = 1;
7330 157127 tile += 2;
7331 157127 break;
7332 }
7333
7334 582791 tile+=f2;
7335 }
7336 582791 break;
7337
7338 case aWALK:
7339 {
7340
5/5
✓ Branch 0 taken 5614 times.
✓ Branch 1 taken 248704 times.
✓ Branch 2 taken 267165 times.
✓ Branch 3 taken 331694 times.
✓ Branch 4 taken 325802 times.
1178979 switch(dir)
7341 {
7342 case up:
7343 248704 tile+=3;
7344 248704 flip = f2;
7345 248704 break;
7346
7347 case down:
7348 267165 tile+=2;
7349 267165 flip = f2;
7350 267165 break;
7351
7352 case left:
7353 331694 flip=1;
7354 331694 tile += f2;
7355 331694 break;
7356
7357 case right:
7358 325802 flip=0;
7359 325802 tile += f2;
7360 325802 break;
7361 }
7362 }
7363 1178979 break;
7364
7365 case aDWALK:
7366 {
7367
3/4
✓ Branch 0 taken 92330 times.
✓ Branch 1 taken 787846 times.
✓ Branch 2 taken 92330 times.
✗ Branch 3 not taken.
880176 if((get_qr(qr_BRKNSHLDTILES)) && (dummy_bool[1]==true))
7368 {
7369 tile=s_tile;
7370 basetile = s_tile;
7371 }
7372
7373
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 177728 times.
✓ Branch 2 taken 185581 times.
✓ Branch 3 taken 260885 times.
✓ Branch 4 taken 255982 times.
880176 switch(dir)
7374 {
7375 case up:
7376 177728 tile+=2;
7377 177728 flip=f2;
7378 177728 break;
7379
7380 case down:
7381 185581 flip=0;
7382 185581 tile+=(1-f2);
7383 185581 break;
7384
7385 case left:
7386 260885 flip=1;
7387 260885 tile+=(3+f2);
7388 260885 break;
7389
7390 case right:
7391 255982 flip=0;
7392 255982 tile+=(3+f2);
7393 255982 break;
7394 }
7395 }
7396 880176 break;
7397
7398 case aTEK:
7399 {
7400
2/2
✓ Branch 0 taken 139654 times.
✓ Branch 1 taken 79014 times.
218668 if(misc==0)
7401 {
7402 79014 tile += f2;
7403 79014 }
7404
2/2
✓ Branch 0 taken 72936 times.
✓ Branch 1 taken 66718 times.
139654 else if(misc!=1)
7405 {
7406 66718 ++tile;
7407 66718 }
7408 }
7409 218668 break;
7410
7411 case aNEWTEK:
7412 {
7413
2/2
✓ Branch 0 taken 474700 times.
✓ Branch 1 taken 1337360 times.
1812060 if(step<0) //up
7414 {
7415
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 235321 times.
✓ Branch 2 taken 239379 times.
474700 switch(clk3)
7416 {
7417 case left:
7418 235321 flip=0;
7419 235321 tile+=20;
7420 235321 break;
7421
7422 case right:
7423 239379 flip=0;
7424 239379 tile+=24;
7425 239379 break;
7426 }
7427 474700 }
7428
2/2
✓ Branch 0 taken 54741 times.
✓ Branch 1 taken 1282619 times.
1337360 else if(step==0)
7429 {
7430
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 40562 times.
✓ Branch 2 taken 14179 times.
54741 switch(clk3)
7431 {
7432 case left:
7433 40562 flip=0;
7434 40562 tile+=8;
7435 40562 break;
7436
7437 case right:
7438 14179 flip=0;
7439 14179 tile+=12;
7440 14179 break;
7441 }
7442 54741 } //down
7443 else
7444 {
7445
3/3
✓ Branch 0 taken 104875 times.
✓ Branch 1 taken 592792 times.
✓ Branch 2 taken 584952 times.
1282619 switch(clk3)
7446 {
7447 case left:
7448 592792 flip=0;
7449 592792 tile+=28;
7450 592792 break;
7451
7452 case right:
7453 584952 flip=0;
7454 584952 tile+=32;
7455 584952 break;
7456 }
7457 }
7458
7459
2/2
✓ Branch 0 taken 1232959 times.
✓ Branch 1 taken 579101 times.
1812060 if(misc==0)
7460 {
7461 579101 tile+=f4;
7462 579101 }
7463
2/2
✓ Branch 0 taken 577625 times.
✓ Branch 1 taken 655334 times.
1232959 else if(misc!=1)
7464 {
7465 655334 tile+=2;
7466 655334 }
7467 }
7468 1812060 break;
7469
7470 case aARMOS:
7471 {
7472
2/2
✓ Branch 0 taken 3227 times.
✓ Branch 1 taken 5401 times.
8628 if(!fading)
7473 {
7474 5401 tile += fx;
7475
7476
2/2
✓ Branch 0 taken 4204 times.
✓ Branch 1 taken 1197 times.
5401 if(dir==up)
7477 1197 tile += 2;
7478 5401 }
7479 }
7480 8628 break;
7481
7482 case aARMOS4:
7483 {
7484
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 28561 times.
✓ Branch 2 taken 88030 times.
✓ Branch 3 taken 42992 times.
✓ Branch 4 taken 42164 times.
201747 switch(dir)
7485 {
7486 case up:
7487 28561 flip=0;
7488 28561 break;
7489
7490 case down:
7491 88030 flip=0;
7492 88030 tile+=4;
7493 88030 break;
7494
7495 case left:
7496 42992 flip=0;
7497 42992 tile+=8;
7498 42992 break;
7499
7500 case right:
7501 42164 flip=0;
7502 42164 tile+=12;
7503 42164 break;
7504 }
7505
7506
2/2
✓ Branch 0 taken 59727 times.
✓ Branch 1 taken 142020 times.
201747 if(!fading)
7507 {
7508 142020 tile+=f4;
7509 142020 }
7510 }
7511 201747 break;
7512
7513 case aGHINI:
7514 {
7515
4/4
✓ Branch 0 taken 28037 times.
✓ Branch 1 taken 32092 times.
✓ Branch 2 taken 72763 times.
✓ Branch 3 taken 452 times.
133344 switch(dir)
7516 {
7517 case 8:
7518 case 9:
7519 case up:
7520 28037 ++tile;
7521 28037 flip=0;
7522 28037 break;
7523
7524 case 15:
7525 452 ++tile;
7526 452 flip=1;
7527 452 break;
7528
7529 case 10:
7530 case 11:
7531 case right:
7532 32092 flip=1;
7533 32092 break;
7534
7535 default:
7536 72763 flip=0;
7537 72763 break;
7538 }
7539 }
7540 133344 break;
7541
7542 case a2FRMPOS:
7543 {
7544 1755010 tile+=posframe;
7545 }
7546 1755010 break;
7547
7548 case a4FRMPOS4DIR:
7549 {
7550 363745 basetile = n_frame_n_dir(4,4,0);
7551 // tile+=f2;
7552 363745 tile+=posframe;
7553 }
7554 363745 break;
7555
7556 case a4FRMPOS4DIRF:
7557 {
7558 1433 basetile = n_frame_n_dir(4,4,0);
7559
7560
2/2
✓ Branch 0 taken 1236 times.
✓ Branch 1 taken 197 times.
1433 if(clk2>0) //stopped to fire
7561 {
7562 197 tile+=20;
7563
7564
2/2
✓ Branch 0 taken 133 times.
✓ Branch 1 taken 64 times.
197 if(clk2<17) //firing
7565 {
7566 64 tile+=20;
7567 64 }
7568 197 }
7569
7570 // tile+=f2;
7571 1433 tile+=posframe;
7572 }
7573 1433 break;
7574
7575 case a4FRMPOS8DIR:
7576 {
7577 6953976 tilerows = 2;
7578 6953976 int32_t n = tile;
7579 6953976 basetile = n_frame_n_dir(4,8,0);
7580 // tile+=f2;
7581 6953976 tile+=posframe;
7582 }
7583 6953976 break;
7584
7585 case a4FRMPOS8DIRF:
7586 {
7587 tilerows = 2;
7588 basetile = n_frame_n_dir(4,8,0);
7589
7590 if(clk2>0) //stopped to fire
7591 {
7592 tile+=40;
7593
7594 if(clk2<17) //firing
7595 {
7596 tile+=40;
7597 }
7598 }
7599
7600 tile+=posframe;
7601 }
7602 break;
7603
7604 case aNEWLEV:
7605 {
7606 747030 tiledir(dir,true);
7607
7608
4/5
✓ Branch 0 taken 258994 times.
✓ Branch 1 taken 115368 times.
✓ Branch 2 taken 48980 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 323688 times.
747030 switch(misc)
7609 {
7610 case -1:
7611 case 0:
7612 258994 return;
7613
7614 case 1:
7615
7616 // case 5: cs = d->misc2; break;
7617 case 5:
7618 115368 cs = dmisc2;
7619 115368 break;
7620
7621 case 2:
7622 case 4:
7623 48980 tile += 20;
7624 48980 break;
7625
7626 case 3:
7627 323688 tile += 40;
7628 323688 break;
7629 }
7630
7631 488036 tile+=f4;
7632 }
7633 488036 break;
7634
7635 case aLEV:
7636 {
7637 276997 f4 = ((clk/5)&1);
7638
7639
4/5
✓ Branch 0 taken 127945 times.
✓ Branch 1 taken 33336 times.
✓ Branch 2 taken 14658 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 101058 times.
276997 switch(misc)
7640 {
7641 case -1:
7642 case 0:
7643 127945 return;
7644
7645 case 1:
7646
7647 // case 5: tile += (f2) ? 1 : 0; cs = d->misc2; break;
7648 case 5:
7649 33336 tile += (f2) ? 1 : 0;
7650 33336 cs = dmisc2;
7651 33336 break;
7652
7653 case 2:
7654 case 4:
7655 14658 tile += 2;
7656 14658 break;
7657
7658 case 3:
7659 101058 tile += (f4) ? 4 : 3;
7660 101058 break;
7661 }
7662 }
7663 149052 break;
7664
7665 case aWALLM:
7666 {
7667
2/2
✓ Branch 0 taken 750 times.
✓ Branch 1 taken 139764 times.
140514 if(!dummy_bool[1])
7668 {
7669 139764 tile += f2;
7670 139764 }
7671 }
7672 140514 break;
7673
7674 case aNEWWALLM:
7675 {
7676 366633 int32_t tempdir=0;
7677
7678
4/4
✓ Branch 0 taken 38855 times.
✓ Branch 1 taken 43340 times.
✓ Branch 2 taken 8438 times.
✓ Branch 3 taken 276000 times.
366633 switch(misc)
7679 {
7680 case 1:
7681 case 2:
7682 43340 tempdir=clk3;
7683 43340 break;
7684
7685 case 3:
7686 case 4:
7687 case 5:
7688 38855 tempdir=dir;
7689 38855 break;
7690
7691 case 6:
7692 case 7:
7693 8438 tempdir=clk3^1;
7694 8438 break;
7695 }
7696
7697 366633 tiledir(tempdir,true);
7698
7699
2/2
✓ Branch 0 taken 1908 times.
✓ Branch 1 taken 364725 times.
366633 if(!dummy_bool[1])
7700 {
7701 364725 tile+=f4;
7702 364725 }
7703 }
7704 366633 break;
7705
7706 case a4FRMNODIR:
7707 {
7708 171508 tile+=f4;
7709 }
7710 171508 break;
7711
7712 } // switch(d->anim)
7713
7714 // flashing
7715 // if(d->flags & guy_flashing)
7716
2/2
✓ Branch 0 taken 38766645 times.
✓ Branch 1 taken 743628 times.
39510273 if(flags & guy_flashing)
7717 {
7718 743628 cs = (frame&3) + 6;
7719 743628 }
7720
7721
2/2
✓ Branch 0 taken 39099325 times.
✓ Branch 1 taken 410948 times.
39510273 if(flags&guy_transparent)
7722 {
7723 410948 drawstyle=1;
7724 410948 }
7725
7726 39510273 int32_t change = tile-basetile;
7727
7728
3/6
✓ Branch 0 taken 1945893 times.
✓ Branch 1 taken 37564380 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1945893 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
39510273 if(extend > 2 && (!ignore_extend || get_qr(qr_BROKEN_BIG_ENEMY_ANIMATION)))
7729 {
7730
2/2
✓ Branch 0 taken 1683865 times.
✓ Branch 1 taken 262028 times.
1945893 if(basetile/TILES_PER_ROW==(basetile+((txsz*change)/tilerows))/TILES_PER_ROW)
7731 {
7732 1683865 tile=basetile+txsz*change;
7733 1683865 }
7734 else
7735 {
7736 262028 tile=basetile+(txsz*change)+((tysz-1)*TILES_PER_ROW)*(((basetile+txsz*change)/TILES_PER_ROW)-(basetile/TILES_PER_ROW));
7737 }
7738 1945893 }
7739 else
7740 {
7741 37564380 tile=basetile+change;
7742 }
7743 39899525 }
7744
7745 81078 int32_t enemy::wpnsfx(int32_t wpn)
7746 {
7747
3/3
✓ Branch 0 taken 22419 times.
✓ Branch 1 taken 40952 times.
✓ Branch 2 taken 17707 times.
81078 switch (wpn)
7748 {
7749 case wScript1:
7750 case wScript2:
7751 case wScript3:
7752 case wScript4:
7753 case wScript5:
7754 case wScript6:
7755 case wScript7:
7756 case wScript8:
7757 case wScript9:
7758 case wScript10: //sure why not
7759 case ewFireTrail:
7760 case ewFlame:
7761 case ewFlame2Trail:
7762 case ewFlame2:
7763 case ewWind:
7764 case ewMagic:
7765 case ewIce:
7766 22419 return firesfx;
7767
7768 case ewRock:
7769 case ewFireball2:
7770 case ewFireball:
7771
2/2
✓ Branch 0 taken 5494 times.
✓ Branch 1 taken 35458 times.
40952 if (get_qr(qr_MORESOUNDS)) return firesfx;
7772 35458 break;
7773 }
7774
7775 53165 return 0;
7776 81078 }
7777
7778 76641003 int32_t enemy::run_script(int32_t mode)
7779 {
7780
3/4
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 76640747 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 256 times.
76641003 if(switch_hooked && !get_qr(qr_SWITCHOBJ_RUN_SCRIPT)) return RUNSCRIPT_OK;
7781
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 76640747 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
76640747 if (script <= 0 || FFCore.getQuestHeaderInfo(vZelda) < 0x255 || FFCore.system_suspend[susptNPCSCRIPTS])
7782 76640747 return RUNSCRIPT_OK;
7783 auto scrty = *get_scrtype();
7784 auto uid = getUID();
7785 if(!FFCore.doscript(scrty,uid))
7786 return RUNSCRIPT_OK;
7787 int32_t ret = RUNSCRIPT_OK;
7788 bool& waitdraw = FFCore.waitdraw(scrty, uid);
7789 switch(mode)
7790 {
7791 case MODE_NORMAL:
7792 return ZScriptVersion::RunScript(ScriptType::NPC, script, uid);
7793 case MODE_WAITDRAW:
7794 if(waitdraw)
7795 {
7796 ret = ZScriptVersion::RunScript(ScriptType::NPC, script, uid);
7797 waitdraw = false;
7798 }
7799 break;
7800 }
7801 return ret;
7802 76641003 }
7803 ALLEGRO_COLOR enemy::hitboxColor(byte opacity) const
7804 {
7805 return al_map_rgba(255,0,0,opacity);
7806 }
7807
7808 // good guys, fires, fairy, and other non-enemies
7809 // based on enemy class b/c guys in dungeons act sort of like enemies
7810 // also easier to manage all the guys this way
7811 2181 guy::guy(zfix X,zfix Y,int32_t Id,int32_t Clk,bool mg) : enemy(X,Y,Id,Clk)
7812 2181 {
7813 2181 mainguy=mg;
7814 2181 canfreeze=false;
7815 2181 dir=down;
7816
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2181 times.
✓ Branch 2 taken 2181 times.
✗ Branch 3 not taken.
2181 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
7817 2181 hxofs=2;
7818 2181 hzsz=8;
7819 2181 hit_width=12;
7820 2181 hit_height=17;
7821
7822
10/12
✓ Branch 0 taken 2181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2181 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 765 times.
✓ Branch 5 taken 1416 times.
✓ Branch 6 taken 743 times.
✓ Branch 7 taken 22 times.
✓ Branch 8 taken 276 times.
✓ Branch 9 taken 467 times.
✓ Branch 10 taken 16 times.
✓ Branch 11 taken 260 times.
2181 if(!superman && (!isdungeon() || id==gFAIRY || id==gFIRE || id==gZELDA))
7823 {
7824 1921 superman = 1;
7825 1921 hxofs=1000;
7826 1921 }
7827 2181 }
7828
7829 940705 bool guy::animate(int32_t index)
7830 {
7831
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 940705 times.
940705 if(switch_hooked) return enemy::animate(index);
7832
6/6
✓ Branch 0 taken 541527 times.
✓ Branch 1 taken 399178 times.
✓ Branch 2 taken 8225 times.
✓ Branch 3 taken 533302 times.
✓ Branch 4 taken 7025 times.
✓ Branch 5 taken 1200 times.
940705 if(mainguy && clk==0 && misc==0)
7833 {
7834 1200 setupscreen();
7835 1200 misc = 1;
7836 1200 }
7837
7838
4/4
✓ Branch 0 taken 541527 times.
✓ Branch 1 taken 399178 times.
✓ Branch 2 taken 541198 times.
✓ Branch 3 taken 329 times.
940705 if(mainguy && fadeclk==0)
7839 329 return true;
7840
7841 940376 hp=256; // good guys never die...
7842
7843
4/4
✓ Branch 0 taken 922 times.
✓ Branch 1 taken 939454 times.
✓ Branch 2 taken 906 times.
✓ Branch 3 taken 16 times.
940376 if(hclk && !clk2)
7844 {
7845 // but if they get hit...
7846 16 ++clk2; // only do this once
7847
7848
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 7 times.
16 if(!get_qr(qr_NOGUYFIRES))
7849 {
7850 7 addenemy(BSZ?64:72,68,eSHOOTFBALL,0);
7851 7 addenemy(BSZ?176:168,68,eSHOOTFBALL,0);
7852 7 }
7853 16 }
7854
7855 940376 return enemy::animate(index);
7856 940705 }
7857
7858 944475 void guy::draw(BITMAP *dest)
7859 {
7860 944475 update_enemy_frame();
7861
7862
6/6
✓ Branch 0 taken 545090 times.
✓ Branch 1 taken 399385 times.
✓ Branch 2 taken 22845 times.
✓ Branch 3 taken 522245 times.
✓ Branch 4 taken 11031 times.
✓ Branch 5 taken 11814 times.
944475 if(!mainguy || fadeclk<0 || fadeclk&1)
7863 932661 enemy::draw(dest);
7864 944475 }
7865
7866 759 eFire::eFire(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
7867 759 {
7868 759 clk4=0;
7869
4/8
✓ Branch 0 taken 759 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 759 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 759 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 759 times.
✗ Branch 7 not taken.
759 shield= (flags&(guy_shield_left | guy_shield_right | guy_shield_back |guy_shield_front)) != 0;
7870 // Spawn type
7871
2/4
✓ Branch 0 taken 759 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 759 times.
759 if(flags & guy_fade_flicker)
7872 {
7873 clk=0;
7874 superman = 1;
7875 fading=fade_flicker;
7876 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
7877 dir=down;
7878
7879 if(!canmove(down,(zfix)8,spw_none,false))
7880 clk3=int32_t(13.0/step);
7881 }
7882
3/4
✓ Branch 0 taken 759 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 676 times.
✓ Branch 3 taken 83 times.
759 else if(flags & guy_fade_instant)
7883 {
7884 83 clk=0;
7885 83 }
7886
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 759 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
759 if (SIZEflags != 0) init_size_flags();;
7887 759 }
7888
7889 167471 bool eFire::animate(int32_t index)
7890 {
7891
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 167471 times.
167471 if(switch_hooked) return enemy::animate(index);
7892
2/4
✓ Branch 0 taken 167471 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 167471 times.
167471 if(fallclk||drownclk) return enemy::animate(index);
7893
2/2
✓ Branch 0 taken 165755 times.
✓ Branch 1 taken 1716 times.
167471 if(fading)
7894 {
7895
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1715 times.
1716 if(++clk4 > 60)
7896 {
7897 1 clk4=0;
7898 1 superman=0;
7899 1 fading=0;
7900
7901
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1 if(flags&guy_armos && z==0 && fakez==0)
7902 removearmos(x,y,ffcactivated);
7903
7904 1 clk2=0;
7905
7906
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(!canmove(down,(zfix)8,spw_none,false))
7907 {
7908 1 dir=0;
7909 1 y = y.getInt() & 0xF0;
7910 1 }
7911
7912 1 return Dead(index);
7913 }
7914
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1715 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1715 else if(flags&guy_armos && z==0 && fakez==0 && clk==0)
7915 removearmos(x,y,ffcactivated);
7916 1715 }
7917
7918 167470 return enemy::animate(index);
7919 167471 }
7920
7921 351657 void eFire::draw(BITMAP *dest)
7922 {
7923 351657 update_enemy_frame();
7924 351657 enemy::draw(dest);
7925 351657 }
7926
7927 415 int32_t eFire::takehit(weapon *w, weapon* realweap)
7928 {
7929 415 int32_t wpnId = w->id;
7930 415 int32_t wpnDir = w->dir;
7931
7932
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
415 if(wpnId==wHammer && shield && (flags & guy_bkshield)
7933 && ((flags&guy_shield_front && wpnDir==(dir^down)) || (flags&guy_shield_back && wpnDir==(dir^up))
7934 || (flags&guy_shield_left && wpnDir==(dir^left)) || (flags&guy_shield_right && wpnDir==(dir^right))))
7935 {
7936 shield = false;
7937 flags &= ~(guy_shield_left|guy_shield_right|guy_shield_back|guy_shield_front);
7938
7939 if(get_qr(qr_BRKNSHLDTILES))
7940 o_tile=s_tile;
7941 }
7942
7943 415 int32_t ret = enemy::takehit(w,realweap);
7944 415 return ret;
7945 }
7946
7947 void eFire::break_shield()
7948 {
7949 if(!shield)
7950 return;
7951
7952 flags&=~(guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right);
7953 shield=false;
7954
7955 if(get_qr(qr_BRKNSHLDTILES))
7956 o_tile=s_tile;
7957 }
7958
7959 void eFire::repair_shield()
7960 {
7961 if (shield)
7962 return;
7963
7964 if (!(flags & (guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right)))
7965 return;
7966
7967 shield = true;
7968
7969 if (get_qr(qr_BRKNSHLDTILES))
7970 {
7971 if get_qr(qr_NEWENEMYTILES) o_tile = d->e_tile;
7972 else o_tile = d->tile;
7973 }
7974 }
7975
7976 7330 eOther::eOther(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
7977 7330 {
7978 7330 clk4=0;
7979
4/8
✓ Branch 0 taken 7330 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7330 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7330 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 7330 times.
✗ Branch 7 not taken.
7330 shield= (flags&(guy_shield_left | guy_shield_right | guy_shield_back |guy_shield_front)) != 0;
7980
7981 // Spawn type
7982
2/4
✓ Branch 0 taken 7330 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7330 times.
7330 if(flags & guy_fade_flicker)
7983 {
7984 clk=0;
7985 superman = 1;
7986 fading=fade_flicker;
7987 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
7988 dir=down;
7989
7990 if(!canmove(down,(zfix)8,spw_none,false))
7991 clk3=int32_t(13.0/step);
7992 }
7993
3/4
✓ Branch 0 taken 7330 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6149 times.
✓ Branch 3 taken 1181 times.
7330 else if(flags & guy_fade_instant)
7994 {
7995 1181 clk=0;
7996 1181 }
7997
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 7323 times.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
7330 if (SIZEflags != 0) init_size_flags();;
7998 7330 }
7999
8000 1875097 bool eOther::animate(int32_t index)
8001 {
8002
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1875097 times.
1875097 if(switch_hooked) return enemy::animate(index);
8003
3/4
✓ Branch 0 taken 1873580 times.
✓ Branch 1 taken 1517 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1873580 times.
1875097 if(fallclk||drownclk) return enemy::animate(index);
8004
2/2
✓ Branch 0 taken 1865166 times.
✓ Branch 1 taken 8414 times.
1873580 if(fading)
8005 {
8006
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 8387 times.
8414 if(++clk4 > 60)
8007 {
8008 27 clk4=0;
8009 27 superman=0;
8010 27 fading=0;
8011
8012
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
27 if(flags&guy_armos && z==0 && fakez==0)
8013 removearmos(x,y,ffcactivated);
8014
8015 27 clk2=0;
8016
8017
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 2 times.
27 if(!canmove(down,(zfix)8,spw_none,false))
8018 {
8019 2 dir=0;
8020 2 y = y.getInt() & 0xF0;
8021 2 }
8022
8023 27 return Dead(index);
8024 }
8025
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 8387 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
8387 else if(flags&guy_armos && z==0 && fakez==0 && clk==0)
8026 removearmos(x,y,ffcactivated);
8027 8387 }
8028
8029 1873553 return enemy::animate(index);
8030 1875097 }
8031
8032 1978517 void eOther::draw(BITMAP *dest)
8033 {
8034 1978517 update_enemy_frame();
8035 1978517 enemy::draw(dest);
8036 1978517 }
8037
8038 14211 int32_t eOther::takehit(weapon *w, weapon* realweap)
8039 {
8040 14211 int32_t wpnId = w->id;
8041 14211 int32_t wpnDir = w->dir;
8042
8043
3/4
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 14186 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 25 times.
14211 if(wpnId==wHammer && shield && (flags & guy_bkshield)
8044 && ((flags&guy_shield_front && wpnDir==(dir^down)) || (flags&guy_shield_back && wpnDir==(dir^up))
8045 || (flags&guy_shield_left && wpnDir==(dir^left)) || (flags&guy_shield_right && wpnDir==(dir^right))))
8046 {
8047 shield = false;
8048 flags &= ~(guy_shield_left|guy_shield_right|guy_shield_back|guy_shield_front);
8049
8050 if(get_qr(qr_BRKNSHLDTILES))
8051 o_tile=s_tile;
8052 }
8053
8054 14211 int32_t ret = enemy::takehit(w,realweap);
8055 14211 return ret;
8056 }
8057
8058 void eOther::break_shield()
8059 {
8060 if(!shield)
8061 return;
8062
8063 flags&=~(guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right);
8064 shield=false;
8065
8066 if(get_qr(qr_BRKNSHLDTILES))
8067 o_tile=s_tile;
8068 }
8069
8070 void eOther::repair_shield()
8071 {
8072 if (shield)
8073 return;
8074
8075 if (!(flags & (guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right)))
8076 return;
8077
8078 shield = true;
8079
8080 if (get_qr(qr_BRKNSHLDTILES))
8081 {
8082 if get_qr(qr_NEWENEMYTILES) o_tile = d->e_tile;
8083 else o_tile = d->tile;
8084 }
8085 }
8086
8087 eScript::eScript(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8088 {
8089 clk4=0;
8090 shield= (flags&(guy_shield_left | guy_shield_right | guy_shield_back |guy_shield_front)) != 0;
8091
8092 // Spawn type
8093 if(flags & guy_fade_flicker)
8094 {
8095 clk=0;
8096 superman = 1;
8097 fading=fade_flicker;
8098 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
8099 dir=down;
8100
8101 if(!canmove(down,(zfix)8,spw_none,false))
8102 clk3=int32_t(13.0/step);
8103 }
8104 else if(flags & guy_fade_instant)
8105 {
8106 clk=0;
8107 }
8108 if (SIZEflags != 0) init_size_flags();;
8109 }
8110
8111 bool eScript::animate(int32_t index)
8112 {
8113 if(switch_hooked) return enemy::animate(index);
8114 if(fallclk||drownclk) return enemy::animate(index);
8115 if(fading)
8116 {
8117 if(++clk4 > 60)
8118 {
8119 clk4=0;
8120 superman=0;
8121 fading=0;
8122
8123 if(flags&guy_armos && z==0 && fakez==0)
8124 removearmos(x,y,ffcactivated);
8125
8126 clk2=0;
8127
8128 if(!canmove(down,(zfix)8,spw_none,false))
8129 {
8130 dir=0;
8131 y = y.getInt() & 0xF0;
8132 }
8133
8134 return Dead(index);
8135 }
8136 else if(flags&guy_armos && z==0 && fakez==0 && clk==0)
8137 removearmos(x,y,ffcactivated);
8138 }
8139
8140 return enemy::animate(index);
8141 }
8142
8143 void eScript::draw(BITMAP *dest)
8144 {
8145 update_enemy_frame();
8146 enemy::draw(dest);
8147 }
8148
8149 int32_t eScript::takehit(weapon *w, weapon* realweap)
8150 {
8151 int32_t wpnId = w->id;
8152 int32_t wpnDir = w->dir;
8153
8154 if(wpnId==wHammer && shield && (flags & guy_bkshield)
8155 && ((flags&guy_shield_front && wpnDir==(dir^down)) || (flags&guy_shield_back && wpnDir==(dir^up))
8156 || (flags&guy_shield_left && wpnDir==(dir^left)) || (flags&guy_shield_right && wpnDir==(dir^right))))
8157 {
8158 shield = false;
8159 flags &= ~(guy_shield_left|guy_shield_right|guy_shield_back|guy_shield_front);
8160
8161 if(get_qr(qr_BRKNSHLDTILES))
8162 o_tile=s_tile;
8163 }
8164
8165 int32_t ret = enemy::takehit(w,realweap);
8166 return ret;
8167 }
8168
8169 void eScript::break_shield()
8170 {
8171 if(!shield)
8172 return;
8173
8174 flags&=~(guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right);
8175 shield=false;
8176
8177 if(get_qr(qr_BRKNSHLDTILES))
8178 o_tile=s_tile;
8179 }
8180
8181 void eScript::repair_shield()
8182 {
8183 if (shield)
8184 return;
8185
8186 if (!(flags & (guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right)))
8187 return;
8188
8189 shield = true;
8190
8191 if (get_qr(qr_BRKNSHLDTILES))
8192 {
8193 if get_qr(qr_NEWENEMYTILES) o_tile = d->e_tile;
8194 else o_tile = d->tile;
8195 }
8196 }
8197
8198
8199 eFriendly::eFriendly(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8200 {
8201 clk4=0;
8202 hyofs = -32768; //No hitbox initially.
8203 shield= (flags&(guy_shield_left | guy_shield_right | guy_shield_back |guy_shield_front)) != 0;
8204
8205 // Spawn type
8206 if(flags & guy_fade_flicker)
8207 {
8208 clk=0;
8209 superman = 1;
8210 fading=fade_flicker;
8211 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
8212 dir=down;
8213
8214 if(!canmove(down,(zfix)8,spw_none,false))
8215 clk3=int32_t(13.0/step);
8216 }
8217 else if(flags & guy_fade_instant)
8218 {
8219 clk=0;
8220 }
8221 if (SIZEflags != 0) init_size_flags();;
8222 }
8223
8224 bool eFriendly::animate(int32_t index)
8225 {
8226 if(switch_hooked) return enemy::animate(index);
8227 if(fallclk||drownclk) return enemy::animate(index);
8228 if(fading)
8229 {
8230 if(++clk4 > 60)
8231 {
8232 clk4=0;
8233 superman=0;
8234 fading=0;
8235
8236 if(flags&guy_armos && z==0 && fakez==0)
8237 removearmos(x,y,ffcactivated);
8238
8239 clk2=0;
8240
8241 if(!canmove(down,(zfix)8,spw_none,false))
8242 {
8243 dir=0;
8244 y = y.getInt() & 0xF0;
8245 }
8246
8247 return Dead(index);
8248 }
8249 else if(flags&guy_armos && z==0 && fakez==0 && clk==0)
8250 removearmos(x,y,ffcactivated);
8251 }
8252
8253 return enemy::animate(index);
8254 }
8255
8256 void eFriendly::draw(BITMAP *dest)
8257 {
8258 update_enemy_frame();
8259 enemy::draw(dest);
8260 }
8261
8262 int32_t eFriendly::takehit(weapon *w, weapon* realweap)
8263 {
8264 int32_t wpnId = w->id;
8265 int32_t wpnDir = w->dir;
8266
8267 if(wpnId==wHammer && shield && (flags & guy_bkshield)
8268 && ((flags&guy_shield_front && wpnDir==(dir^down)) || (flags&guy_shield_back && wpnDir==(dir^up))
8269 || (flags&guy_shield_left && wpnDir==(dir^left)) || (flags&guy_shield_right && wpnDir==(dir^right))))
8270 {
8271 shield = false;
8272 flags &= ~(guy_shield_left|guy_shield_right|guy_shield_back|guy_shield_front);
8273
8274 if(get_qr(qr_BRKNSHLDTILES))
8275 o_tile=s_tile;
8276 }
8277
8278 int32_t ret = enemy::takehit(w,realweap);
8279 return ret;
8280 }
8281
8282 void eFriendly::break_shield()
8283 {
8284 if(!shield)
8285 return;
8286
8287 flags&=~(guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right);
8288 shield=false;
8289
8290 if(get_qr(qr_BRKNSHLDTILES))
8291 o_tile=s_tile;
8292 }
8293
8294 void eFriendly::repair_shield()
8295 {
8296 if (shield)
8297 return;
8298
8299 if (!(flags & (guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right)))
8300 return;
8301
8302 shield = true;
8303
8304 if (get_qr(qr_BRKNSHLDTILES))
8305 {
8306 if get_qr(qr_NEWENEMYTILES) o_tile = d->e_tile;
8307 else o_tile = d->tile;
8308 }
8309 }
8310
8311
8312 779160 void enemy::removearmos(int32_t ax,int32_t ay, word ffcactive)
8313 {
8314
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 779160 times.
779160 if (ffcactive)
8315 {
8316 removearmosffc(ffcactive-1);
8317 return;
8318 }
8319
2/2
✓ Branch 0 taken 778180 times.
✓ Branch 1 taken 980 times.
779160 if(did_armos)
8320 {
8321 778180 return;
8322 }
8323
8324 980 did_armos=true;
8325 980 ax&=0xF0;
8326 980 ay&=0xF0;
8327 980 int32_t cd = (ax>>4)+ay;
8328 980 int32_t f = MAPFLAG(ax,ay);
8329 980 int32_t f2 = MAPCOMBOFLAG(ax,ay);
8330
8331
2/2
✓ Branch 0 taken 840 times.
✓ Branch 1 taken 140 times.
980 if(combobuf[tmpscr->data[cd]].type!=cARMOS)
8332 {
8333 840 return;
8334 }
8335
8336 140 tmpscr->data[cd] = tmpscr->undercombo;
8337 140 tmpscr->cset[cd] = tmpscr->undercset;
8338 140 tmpscr->sflag[cd] = 0;
8339
8340
3/4
✓ Branch 0 taken 118 times.
✓ Branch 1 taken 22 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 118 times.
140 if(f == mfARMOS_SECRET || f2 == mfARMOS_SECRET)
8341 {
8342 22 tmpscr->data[cd] = tmpscr->secretcombo[sSTAIRS];
8343 22 tmpscr->cset[cd] = tmpscr->secretcset[sSTAIRS];
8344 22 tmpscr->sflag[cd]=tmpscr->secretflag[sSTAIRS];
8345 22 sfx(tmpscr->secretsfx);
8346 22 }
8347
8348
3/4
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 137 times.
140 if(f == mfARMOS_ITEM || f2 == mfARMOS_ITEM)
8349 {
8350
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3 if(!getmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN))
8351 {
8352 3 additem(ax,ay,tmpscr->catchall, (ipONETIME2 + ipBIGRANGE) | ((tmpscr->flags3&fHOLDITEM) ? ipHOLDUP : 0) | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0));
8353 3 sfx(tmpscr->secretsfx);
8354 3 }
8355 3 }
8356
8357 140 putcombo(scrollbuf,ax,ay,tmpscr->data[cd],tmpscr->cset[cd]);
8358 779160 }
8359
8360 void enemy::removearmosffc(int32_t pos)
8361 {
8362 if(did_armos)
8363 {
8364 return;
8365 }
8366
8367 did_armos=true;
8368 ffcdata& ffc = tmpscr->getFFC(pos);
8369 newcombo const& cmb = combobuf[ffc.data];
8370 int32_t f2 = cmb.flag;
8371
8372 if(cmb.type!=cARMOS)
8373 {
8374 return;
8375 }
8376
8377 zc_ffc_set(ffc, tmpscr->undercombo);
8378 ffc.cset = tmpscr->undercset;
8379
8380 if(f2 == mfARMOS_SECRET)
8381 {
8382 zc_ffc_set(ffc, tmpscr->secretcombo[sSTAIRS]);
8383 ffc.cset = tmpscr->secretcset[sSTAIRS];
8384 sfx(tmpscr->secretsfx);
8385 }
8386
8387 if(f2 == mfARMOS_ITEM)
8388 {
8389 if(!getmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN))
8390 {
8391 additem(ffc.x,ffc.y,tmpscr->catchall, (ipONETIME2 + ipBIGRANGE) | ((tmpscr->flags3&fHOLDITEM) ? ipHOLDUP : 0) | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0));
8392 sfx(tmpscr->secretsfx);
8393 }
8394 }
8395
8396 putcombo(scrollbuf,ffc.x,ffc.y,ffc.data,ffc.cset);
8397 }
8398
8399
8400 461 eGhini::eGhini(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8401 461 {
8402 461 fading=fade_flicker;
8403
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 461 times.
461 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
8404 461 dir=12;
8405 461 movestatus=1;
8406
1/2
✓ Branch 0 taken 461 times.
✗ Branch 1 not taken.
461 step=0;
8407 461 clk=0;
8408 461 clk4=0;
8409
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 461 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
461 if (SIZEflags != 0) init_size_flags();;
8410 461 }
8411
8412 117025 bool eGhini::animate(int32_t index)
8413 {
8414
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 117025 times.
117025 if(switch_hooked) return enemy::animate(index);
8415
2/4
✓ Branch 0 taken 117025 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 117025 times.
117025 if(fallclk||drownclk) return enemy::animate(index);
8416
2/2
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 116975 times.
117025 if(dying)
8417 50 return Dead(index);
8418
8419
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116975 times.
116975 if(dmisc1)
8420 {
8421
2/2
✓ Branch 0 taken 89752 times.
✓ Branch 1 taken 27223 times.
116975 if(misc)
8422 {
8423
2/2
✓ Branch 0 taken 34899 times.
✓ Branch 1 taken 54853 times.
89752 if(clk4>160)
8424 54853 misc=2;
8425
8426
2/2
✓ Branch 0 taken 34899 times.
✓ Branch 1 taken 54853 times.
89752 floater_walk((misc==1)?0:rate,hrate,zslongToFix(dstep*100),zslongToFix(dstep*10),10,dmisc16,dmisc17); //120,10);
8427 89752 removearmos(x,y,ffcactivated);
8428 89752 }
8429
2/2
✓ Branch 0 taken 26798 times.
✓ Branch 1 taken 425 times.
27223 else if(clk4>=60)
8430 {
8431 425 misc=1;
8432 425 clk3=32;
8433 425 fading=0;
8434
1/2
✓ Branch 0 taken 425 times.
✗ Branch 1 not taken.
425 if (ffcactivated > 0)
8435 {
8436 guygridffc[ffcactivated-1] = 0;
8437 removearmosffc(ffcactivated-1);
8438 }
8439 else
8440 {
8441 425 guygrid[(int32_t(y)&0xF0)+(int32_t(x)>>4)]=0;
8442 425 removearmos(x,y);
8443 }
8444 425 }
8445 116975 }
8446
8447 116975 clk4++;
8448
8449 116975 return enemy::animate(index);
8450 117025 }
8451
8452 238808 void eGhini::draw(BITMAP *dest)
8453 {
8454 238808 update_enemy_frame();
8455 238808 enemy::draw(dest);
8456 238808 }
8457
8458 2 void eGhini::kickbucket()
8459 {
8460 2 hp=-1000; // don't call death_sfx()
8461 2 }
8462
8463
2/4
✓ Branch 0 taken 5196 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5196 times.
✗ Branch 3 not taken.
10392 eTektite::eTektite(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8464 5196 {
8465
1/2
✓ Branch 0 taken 5196 times.
✗ Branch 1 not taken.
5196 old_y=y;
8466 5196 dir=down;
8467 5196 misc=1;
8468 5196 clk=-15;
8469
8470
2/2
✓ Branch 0 taken 2645 times.
✓ Branch 1 taken 2551 times.
5196 if(!BSZ)
8471
1/2
✓ Branch 0 taken 2645 times.
✗ Branch 1 not taken.
2645 clk*=zc_oldrand()%3+1;
8472
8473 // avoid divide by 0 errors
8474
1/2
✓ Branch 0 taken 5196 times.
✗ Branch 1 not taken.
5196 if(dmisc1 == 0)
8475 dmisc1 = 24;
8476
8477
1/2
✓ Branch 0 taken 5196 times.
✗ Branch 1 not taken.
5196 if(dmisc2 == 0)
8478 dmisc2 = 3;
8479
8480 //nets+760;
8481
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5196 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5196 if (SIZEflags != 0) init_size_flags();;
8482 5196 }
8483
8484 1435270 bool eTektite::animate(int32_t index)
8485 {
8486
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1435270 times.
1435270 if(switch_hooked) return enemy::animate(index);
8487
4/4
✓ Branch 0 taken 1426328 times.
✓ Branch 1 taken 8942 times.
✓ Branch 2 taken 8942 times.
✓ Branch 3 taken 1423838 times.
1435270 if(fallclk||drownclk) return enemy::animate(index);
8488
2/2
✓ Branch 0 taken 26667 times.
✓ Branch 1 taken 1397171 times.
1423838 if(dying)
8489 26667 return Dead(index);
8490
8491
2/2
✓ Branch 0 taken 1360103 times.
✓ Branch 1 taken 37068 times.
1397171 if(clk==0)
8492 {
8493 37068 removearmos(x,y,ffcactivated);
8494 37068 }
8495
8496
2/2
✓ Branch 0 taken 1055988 times.
✓ Branch 1 taken 341183 times.
1397171 if(get_qr(qr_ENEMIESZAXIS))
8497 {
8498 341183 y=floor_y;
8499 341183 }
8500
8501
9/10
✓ Branch 0 taken 1282576 times.
✓ Branch 1 taken 114595 times.
✓ Branch 2 taken 1269012 times.
✓ Branch 3 taken 13564 times.
✓ Branch 4 taken 1269012 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 11176 times.
✓ Branch 7 taken 1257836 times.
✓ Branch 8 taken 12048 times.
✓ Branch 9 taken 21878 times.
1397171 if(clk>=0 && !stunclk && !frozenclock && (!watch || misc==0))
8502 {
8503
4/4
✓ Branch 0 taken 20260 times.
✓ Branch 1 taken 421148 times.
✓ Branch 2 taken 344884 times.
✓ Branch 3 taken 493422 times.
1279714 switch(misc)
8504 {
8505 case 0: // normal
8506
2/2
✓ Branch 0 taken 409927 times.
✓ Branch 1 taken 11221 times.
421148 if(!(zc_oldrand()%dmisc1))
8507 {
8508 11221 misc=1;
8509 11221 clk2=32;
8510 11221 }
8511
8512 421148 break;
8513
8514 case 1: // waiting to pounce
8515
2/2
✓ Branch 0 taken 324265 times.
✓ Branch 1 taken 20619 times.
344884 if(--clk2<=0)
8516 {
8517 20619 int32_t r=zc_oldrand();
8518 20619 misc=2;
8519 20619 step=0-(zslongToFix(dstep*100)); // initial speed
8520 20619 clk3=(r&1)+2; // left or right
8521 20619 clk2start=clk2=(r&31)+10; // flight time
8522
8523
2/2
✓ Branch 0 taken 18196 times.
✓ Branch 1 taken 2423 times.
20619 if(y<32) clk2+=2; // make them come down from top of screen
8524
8525
2/2
✓ Branch 0 taken 15702 times.
✓ Branch 1 taken 4917 times.
20619 if(y>112) clk2-=2; // make them go back up
8526
8527 20619 cstart=c = 9-((r&31)>>3); // time before gravity kicks in
8528 20619 }
8529
8530 344884 break;
8531
8532 case 2: // in flight
8533 493422 move(step);
8534
8535
2/2
✓ Branch 0 taken 234221 times.
✓ Branch 1 taken 259201 times.
493422 if(step>0) //going down
8536 {
8537
2/2
✓ Branch 0 taken 632 times.
✓ Branch 1 taken 233589 times.
234221 if(COMBOTYPE(x+8,y+16)==cNOJUMPZONE)
8538 {
8539 632 step=0-step;
8540 632 }
8541
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 233589 times.
233589 else if(COMBOTYPE(x+8,y+16)==cNOENEMY)
8542 {
8543 step=0-step;
8544 }
8545
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 233589 times.
233589 else if(ispitfall(x+8,y+16))
8546 {
8547 step=0-step;
8548 }
8549
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 233542 times.
233589 else if(MAPFLAG(x+8,y+16)==mfNOENEMY)
8550 {
8551 47 step=0-step;
8552 47 }
8553
2/2
✓ Branch 0 taken 233531 times.
✓ Branch 1 taken 11 times.
233542 else if(MAPCOMBOFLAG(x+8,y+16)==mfNOENEMY)
8554 {
8555 11 step=0-step;
8556 11 }
8557 234221 }
8558
2/2
✓ Branch 0 taken 15154 times.
✓ Branch 1 taken 244047 times.
259201 else if(step<0)
8559 {
8560
2/2
✓ Branch 0 taken 438 times.
✓ Branch 1 taken 243609 times.
244047 if(COMBOTYPE(x+8,y)==cNOJUMPZONE)
8561 {
8562 438 step=0-step;
8563 438 }
8564
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 243609 times.
243609 else if(COMBOTYPE(x+8,y)==cNOENEMY)
8565 {
8566 step=0-step;
8567 }
8568
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 243609 times.
243609 else if(ispitfall(x+8,y))
8569 {
8570 step=0-step;
8571 }
8572
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 243588 times.
243609 else if(MAPFLAG(x+8,y)==mfNOENEMY)
8573 {
8574 21 step=0-step;
8575 21 }
8576
2/2
✓ Branch 0 taken 243569 times.
✓ Branch 1 taken 19 times.
243588 else if(MAPCOMBOFLAG(x+8,y)==mfNOENEMY)
8577 {
8578 19 step=0-step;
8579 19 }
8580 244047 }
8581
8582
2/2
✓ Branch 0 taken 244152 times.
✓ Branch 1 taken 249270 times.
493422 if(clk3==left)
8583 {
8584
2/2
✓ Branch 0 taken 275 times.
✓ Branch 1 taken 243877 times.
244152 if(COMBOTYPE(x,y+8)==cNOJUMPZONE)
8585 {
8586 275 clk3^=1;
8587 275 }
8588
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 243871 times.
243877 else if(COMBOTYPE(x,y+8)==cNOENEMY)
8589 {
8590 6 clk3^=1;
8591 6 }
8592
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 243871 times.
243871 else if(ispitfall(x,y+8))
8593 {
8594 clk3^=1;
8595 }
8596
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 243841 times.
243871 else if(MAPFLAG(x,y+8)==mfNOENEMY)
8597 {
8598 30 clk3^=1;
8599 30 }
8600
2/2
✓ Branch 0 taken 243829 times.
✓ Branch 1 taken 12 times.
243841 else if(MAPCOMBOFLAG(x,y+8)==mfNOENEMY)
8601 {
8602 12 clk3^=1;
8603 12 }
8604 244152 }
8605 else
8606 {
8607
2/2
✓ Branch 0 taken 276 times.
✓ Branch 1 taken 248994 times.
249270 if(COMBOTYPE(x+16,y+8)==cNOJUMPZONE)
8608 {
8609 276 clk3^=1;
8610 276 }
8611
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 248982 times.
248994 else if(COMBOTYPE(x+16,y+8)==cNOENEMY)
8612 {
8613 12 clk3^=1;
8614 12 }
8615
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 248982 times.
248982 else if(ispitfall(x+16,y+8))
8616 {
8617 clk3^=1;
8618 }
8619
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 248977 times.
248982 else if(MAPFLAG(x+16,y+8)==mfNOENEMY)
8620 {
8621 5 clk3^=1;
8622 5 }
8623
2/2
✓ Branch 0 taken 248965 times.
✓ Branch 1 taken 12 times.
248977 else if(MAPCOMBOFLAG(x+16,y+8)==mfNOENEMY)
8624 {
8625 12 clk3^=1;
8626 12 }
8627 }
8628
8629 493422 --c;
8630
8631
4/4
✓ Branch 0 taken 151408 times.
✓ Branch 1 taken 342014 times.
✓ Branch 2 taken 320475 times.
✓ Branch 3 taken 172947 times.
493422 if(c<0 && step<zslongToFix(dstep*100))
8632 {
8633 172947 step+=zslongToFix(dmisc3*100);
8634 172947 }
8635
8636 493422 int32_t nb=get_qr(qr_NOBORDER) ? 16 : 0;
8637
8638
2/2
✓ Branch 0 taken 492701 times.
✓ Branch 1 taken 721 times.
493422 if(x<=16-nb) clk3=right;
8639
8640
2/2
✓ Branch 0 taken 492430 times.
✓ Branch 1 taken 992 times.
493422 if(x>=224+nb) clk3=left;
8641
8642 493422 x += (clk3==left) ? -1 : 1;
8643
8644
4/4
✓ Branch 0 taken 29025 times.
✓ Branch 1 taken 464397 times.
✓ Branch 2 taken 10130 times.
✓ Branch 3 taken 454267 times.
493422 if((--clk2<=0 && y>=16-nb) || y>=144+nb)
8645 {
8646
4/4
✓ Branch 0 taken 1621 times.
✓ Branch 1 taken 17274 times.
✓ Branch 2 taken 1436 times.
✓ Branch 3 taken 185 times.
39155 if(y>=144+nb && get_qr(qr_ENEMIESZAXIS))
8647 {
8648 185 step=0-step;
8649 185 y--;
8650 185 }
8651
2/2
✓ Branch 0 taken 5794 times.
✓ Branch 1 taken 12916 times.
18710 else if(zc_oldrand()%dmisc2) //land and wait
8652 {
8653 12916 clk=misc=0;
8654 12916 } //land and jump again
8655 else
8656 {
8657 5794 misc=1;
8658 5794 clk2=0;
8659 }
8660 18895 }
8661
8662 473162 break;
8663 } // switch
8664 1259454 }
8665
8666
4/4
✓ Branch 0 taken 341183 times.
✓ Branch 1 taken 1058478 times.
✓ Branch 2 taken 231206 times.
✓ Branch 3 taken 109977 times.
1399661 if(get_qr(qr_ENEMIESZAXIS) && misc==2)
8667 {
8668
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109977 times.
109977 if (moveflags & move_use_fake_z)
8669 {
8670 int32_t tempy = floor_y;
8671 fakez=zc_max(0,zc_min(clk2start-clk2,clk2));
8672 floor_y = y;
8673 y=tempy-fakez;
8674 old_y = y;
8675 }
8676 else
8677 {
8678 109977 int32_t tempy = floor_y;
8679
6/6
✓ Branch 0 taken 55216 times.
✓ Branch 1 taken 54761 times.
✓ Branch 2 taken 104073 times.
✓ Branch 3 taken 5904 times.
✓ Branch 4 taken 50747 times.
✓ Branch 5 taken 53326 times.
109977 z=zc_max(0,zc_min(clk2start-clk2,clk2));
8680 109977 floor_y = y;
8681 109977 y=tempy-z;
8682 109977 old_y = y;
8683 }
8684 109977 }
8685
8686
4/4
✓ Branch 0 taken 13564 times.
✓ Branch 1 taken 1386097 times.
✓ Branch 2 taken 2927 times.
✓ Branch 3 taken 10637 times.
1399661 if(stunclk && (clk&31)==1)
8687 10637 clk=0;
8688
8689 1399661 return enemy::animate(index);
8690 1426328 }
8691
8692 803206 void eTektite::drawshadow(BITMAP *dest,bool translucent)
8693 {
8694
5/6
✓ Branch 0 taken 625928 times.
✓ Branch 1 taken 177278 times.
✓ Branch 2 taken 625928 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 600737 times.
✓ Branch 5 taken 25191 times.
803206 if(z<1 && fakez<1 && get_qr(qr_ENEMIESZAXIS))
8695 25191 return;
8696
8697 778015 int32_t tempy=yofs;
8698 778015 int32_t fdiv = frate/4;
8699
1/2
✓ Branch 0 taken 778015 times.
✗ Branch 1 not taken.
778015 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
8700
1/2
✓ Branch 0 taken 778015 times.
✗ Branch 1 not taken.
778015 int32_t f2=get_qr(qr_NEWENEMYTILES)?
8701 778015 efrate:((clk>=(frate>>1))?1:0);
8702 778015 flip = 0;
8703 778015 shadowtile = wpnsbuf[spr_shadow].tile;
8704
8705
1/2
✓ Branch 0 taken 778015 times.
✗ Branch 1 not taken.
778015 if(get_qr(qr_NEWENEMYTILES))
8706 {
8707
2/2
✓ Branch 0 taken 575932 times.
✓ Branch 1 taken 202083 times.
778015 if(misc==0)
8708 {
8709 202083 shadowtile+=f2;
8710 202083 }
8711
2/2
✓ Branch 0 taken 254903 times.
✓ Branch 1 taken 321029 times.
575932 else if(misc!=1)
8712 321029 shadowtile+=2;
8713 778015 }
8714 else
8715 {
8716 if(misc==0)
8717 {
8718 shadowtile += f2 ? 1 : 0;
8719 }
8720 else if(misc!=1)
8721 {
8722 ++shadowtile;
8723 }
8724 }
8725
8726 778015 yofs+=8;
8727
8728
4/4
✓ Branch 0 taken 600737 times.
✓ Branch 1 taken 177278 times.
✓ Branch 2 taken 339908 times.
✓ Branch 3 taken 260829 times.
778015 if(!get_qr(qr_ENEMIESZAXIS) && misc==2)
8729 {
8730
6/6
✓ Branch 0 taken 134073 times.
✓ Branch 1 taken 126756 times.
✓ Branch 2 taken 243385 times.
✓ Branch 3 taken 17444 times.
✓ Branch 4 taken 123475 times.
✓ Branch 5 taken 119910 times.
260829 yofs+=zc_max(0,zc_min(clk2start-clk2,clk2));
8731 260829 }
8732
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 778015 times.
778015 if(!shadow_overpit(this))
8733 778015 enemy::drawshadow(dest,translucent);
8734 778015 yofs=tempy;
8735 803206 }
8736
8737 2045360 void eTektite::draw(BITMAP *dest)
8738 {
8739 2045360 update_enemy_frame();
8740 2045360 enemy::draw(dest);
8741 2045360 }
8742
8743 730 eItemFairy::eItemFairy(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8744 730 {
8745
2/4
✓ Branch 0 taken 730 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 730 times.
✗ Branch 3 not taken.
730 step=zslongToFix(guysbuf[id&0xFFF].step*100);
8746 730 superman=1;
8747 730 dir=8;
8748 730 hxofs=1000;
8749 730 mainguy=false;
8750 730 count_enemy=false;
8751
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 730 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
730 if (SIZEflags != 0) init_size_flags();;
8752 730 }
8753
8754 279897 bool eItemFairy::animate(int32_t index)
8755 {
8756
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 279897 times.
279897 if(switch_hooked) return enemy::animate(index);
8757
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 279897 times.
279897 if(dying)
8758 return Dead(index);
8759
8760 //if(clk>32)
8761 279897 misc=1;
8762 279897 bool w=watch;
8763 279897 watch=false;
8764 279897 variable_walk_8(misc?3:0,0,8,spw_floater);
8765 279897 watch=w;
8766
8767
2/2
✓ Branch 0 taken 1514 times.
✓ Branch 1 taken 278383 times.
279897 if(clk==0)
8768 {
8769 1514 removearmos(x,y,ffcactivated);
8770 1514 }
8771
8772 279897 return enemy::animate(index);
8773 279897 }
8774
8775 562150 void eItemFairy::draw(BITMAP *dest)
8776 {
8777 //these are here to bypass compiler warnings about unused arguments
8778 562150 dest=dest;
8779 562150 }
8780
8781 1825 ePeahat::ePeahat(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8782 1825 {
8783 //floater_walk(int32_t rate,int32_t newclk,zfix ms,zfix ss,int32_t s,int32_t p, int32_t g)
8784
10/20
✗ Branch 0 not taken.
✓ Branch 1 taken 1825 times.
✓ Branch 2 taken 1825 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1825 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1825 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1825 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1825 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1825 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1825 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 1825 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 1825 times.
✗ Branch 19 not taken.
1825 floater_walk(misc?rate:0, hrate, zslongToFix(dstep*100),zslongToFix(dstep*10), 10, dmisc16,dmisc17); // 80, 16);
8785 1825 dir=8;
8786 1825 movestatus=1;
8787 1825 clk=0;
8788
1/2
✓ Branch 0 taken 1825 times.
✗ Branch 1 not taken.
1825 step=0;
8789 //nets+720;
8790
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1825 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1825 if (SIZEflags != 0) init_size_flags();;
8791 1825 }
8792
8793 520615 bool ePeahat::animate(int32_t index)
8794 {
8795
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 520615 times.
520615 if(switch_hooked) return enemy::animate(index);
8796
2/4
✓ Branch 0 taken 520615 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 520615 times.
520615 if(fallclk||drownclk) return enemy::animate(index);
8797
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 520537 times.
520615 if(slide())
8798 {
8799 78 return false;
8800 }
8801
8802
2/2
✓ Branch 0 taken 1030 times.
✓ Branch 1 taken 519507 times.
520537 if(dying)
8803 1030 return Dead(index);
8804
8805
2/2
✓ Branch 0 taken 3083 times.
✓ Branch 1 taken 516424 times.
519507 if(clk==0)
8806 {
8807 3083 removearmos(x,y,ffcactivated);
8808 3083 }
8809
8810
4/4
✓ Branch 0 taken 516389 times.
✓ Branch 1 taken 3118 times.
✓ Branch 2 taken 253336 times.
✓ Branch 3 taken 263053 times.
519507 if(stunclk==0 && clk>96)
8811 263053 misc=1;
8812
8813
2/2
✓ Branch 0 taken 2402 times.
✓ Branch 1 taken 517105 times.
519507 if(!watch)
8814
2/2
✓ Branch 0 taken 171491 times.
✓ Branch 1 taken 345614 times.
517105 floater_walk(misc?rate:0, hrate, zslongToFix(dstep*100),zslongToFix(dstep*10), 10, 80, 16);
8815
8816
3/4
✓ Branch 0 taken 100018 times.
✓ Branch 1 taken 419489 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 100018 times.
519507 if(get_qr(qr_ENEMIESZAXIS) && !(isSideViewGravity()))
8817 {
8818
1/2
✓ Branch 0 taken 100018 times.
✗ Branch 1 not taken.
100018 if (moveflags & move_use_fake_z) fakez=int32_t(step*1.1/((zslongToFix(dstep*10))*1.1));
8819 100018 else z=int32_t(step*1.1/((zslongToFix(dstep*10))*1.1));
8820 100018 }
8821
8822
4/4
✓ Branch 0 taken 2402 times.
✓ Branch 1 taken 517105 times.
✓ Branch 2 taken 768 times.
✓ Branch 3 taken 1634 times.
519507 if(watch && get_qr(qr_PEAHATCLOCKVULN))
8823 1634 superman=0;
8824 else
8825
2/2
✓ Branch 0 taken 9811 times.
✓ Branch 1 taken 508062 times.
517873 superman=(movestatus && !get_qr(qr_ENEMIESZAXIS)) ? 1 : 0;
8826 //stunclk=0; //Not sure what was going on here, or what was intended. Why was this set to 0? -Z
8827
2/2
✓ Branch 0 taken 264937 times.
✓ Branch 1 taken 254570 times.
519507 if ( FFCore.getQuestHeaderInfo(vZelda) >= 0x250 )
8828 {
8829
2/2
✓ Branch 0 taken 261822 times.
✓ Branch 1 taken 3115 times.
264937 if ( stunclk ) --stunclk;
8830 264937 }
8831 254570 else stunclk = 0; //Was probably this way in 2.10 quests. if not, then we never need to clear it. -Z
8832 //Pretty sure this was always an error. -Z ( 14FEB2019 )
8833
8834
8835
2/2
✓ Branch 0 taken 519267 times.
✓ Branch 1 taken 240 times.
519507 if(x<16) dir=right; //this is ugly, but so is moving or creating these guys with scripts.
8836
8837 519507 return enemy::animate(index);
8838 520615 }
8839
8840 334520 void ePeahat::drawshadow(BITMAP *dest, bool translucent)
8841 {
8842 334520 int32_t tempy=yofs;
8843 334520 flip = 0;
8844 334520 shadowtile = wpnsbuf[spr_shadow].tile+posframe;
8845
8846
2/2
✓ Branch 0 taken 88089 times.
✓ Branch 1 taken 246431 times.
334520 if(!get_qr(qr_ENEMIESZAXIS))
8847 {
8848 246431 yofs+=8;
8849 246431 yofs+=int32_t(step/zslongToFix(dstep*10));
8850 246431 }
8851
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 334520 times.
334520 if(!shadow_overpit(this))
8852 334520 enemy::drawshadow(dest,translucent);
8853 334520 yofs=tempy;
8854 334520 }
8855
8856 1144330 void ePeahat::draw(BITMAP *dest)
8857 {
8858 1144330 update_enemy_frame();
8859 1144330 enemy::draw(dest);
8860 1144330 }
8861
8862 4136 int32_t ePeahat::takehit(weapon *w, weapon* realweap)
8863 {
8864 4136 int32_t wpnId = w->id;
8865 4136 int32_t enemyHitWeapon = w->parentitem;
8866
8867
3/6
✓ Branch 0 taken 4136 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4136 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4136 times.
4136 if(dying || clk<0 || hclk>0)
8868 return 0;
8869
8870
4/4
✓ Branch 0 taken 3381 times.
✓ Branch 1 taken 755 times.
✓ Branch 2 taken 38 times.
✓ Branch 3 taken 206 times.
4380 if(superman && !(wpnId==wSBomb) // vulnerable to super bombs
8871 // fire boomerang, for nailing peahats
8872
4/6
✓ Branch 0 taken 3381 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3137 times.
✓ Branch 3 taken 244 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 244 times.
3381 && !(wpnId==wBrang && (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_brang))>0))
8873 3343 return 0;
8874
8875 // Time for a kludge...
8876 793 int32_t s = superman;
8877 793 superman = 0;
8878 793 int32_t ret = enemy::takehit(w,realweap);
8879 793 superman = s;
8880
8881 // Anyway...
8882
2/2
✓ Branch 0 taken 601 times.
✓ Branch 1 taken 192 times.
793 if(stunclk == 160)
8883 {
8884 192 clk2=0;
8885 192 movestatus=0;
8886 192 misc=0;
8887 192 clk=0;
8888 192 step=0;
8889 192 }
8890
8891 793 return ret;
8892 4136 }
8893
8894 // auomatically kill off enemy (for rooms with ringleaders)
8895 void ePeahat::kickbucket()
8896 {
8897 hp=-1000; // don't call death_sfx()
8898 }
8899
8900 3942 eLeever::eLeever(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8901 3942 {
8902 // if(d->misc1==0) { misc=-1; clk-=16; } //Line of Sight leevers
8903
2/2
✓ Branch 0 taken 1795 times.
✓ Branch 1 taken 2147 times.
3942 if(dmisc1==0)
8904 {
8905 2147 misc=-1; //Line of Sight leevers
8906 2147 clk-=16;
8907 2147 }
8908 3942 clk3 = 0;
8909 //nets+1460;
8910 3942 temprule=(get_qr(qr_NEWENEMYTILES)) != 0;
8911 3942 submerged = false;
8912
1/4
✓ Branch 0 taken 3942 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3942 if (SIZEflags != 0) init_size_flags();;
8913 3942 }
8914
8915 923 bool eLeever::isSubmerged() const
8916 {
8917 923 Z_scripterrlog("misc is: %d\n", misc);
8918 923 return misc <= 0;
8919
8920 }
8921
8922 1018478 bool eLeever::animate(int32_t index)
8923 {
8924
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1018478 times.
1018478 if(switch_hooked) return enemy::animate(index);
8925
3/4
✓ Branch 0 taken 1018123 times.
✓ Branch 1 taken 355 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1018123 times.
1018478 if(fallclk||drownclk)
8926 {
8927 355 return enemy::animate(index);
8928 }
8929
2/2
✓ Branch 0 taken 31552 times.
✓ Branch 1 taken 986571 times.
1018123 if(dying)
8930 31552 return Dead(index);
8931
8932
2/2
✓ Branch 0 taken 941601 times.
✓ Branch 1 taken 44970 times.
986571 if(clk==0)
8933 {
8934 44970 removearmos(x,y,ffcactivated);
8935 44970 }
8936
8937
4/4
✓ Branch 0 taken 816947 times.
✓ Branch 1 taken 169624 times.
✓ Branch 2 taken 5265 times.
✓ Branch 3 taken 811682 times.
986571 if(clk>=0 && !slide())
8938 {
8939 // switch(d->misc1)
8940
2/2
✓ Branch 0 taken 337868 times.
✓ Branch 1 taken 473814 times.
811682 switch(dmisc1)
8941 {
8942 case 0: //line of sight
8943 case 2:
8944
7/8
✗ Branch 0 not taken.
✓ Branch 1 taken 124459 times.
✓ Branch 2 taken 49109 times.
✓ Branch 3 taken 35464 times.
✓ Branch 4 taken 15780 times.
✓ Branch 5 taken 101784 times.
✓ Branch 6 taken 4365 times.
✓ Branch 7 taken 6907 times.
337868 switch(misc) //is this leever active
8945 {
8946 case -1: //submerged
8947 {
8948
4/6
✓ Branch 0 taken 6382 times.
✓ Branch 1 taken 118077 times.
✓ Branch 2 taken 6382 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6382 times.
124459 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk)) misc = 0;
8949
4/4
✓ Branch 0 taken 10299 times.
✓ Branch 1 taken 114160 times.
✓ Branch 2 taken 10261 times.
✓ Branch 3 taken 38 times.
124459 if((dmisc1==2)&&(zc_oldrand()&255))
8950 {
8951 10261 break;
8952 }
8953
8954 114198 int32_t active=0;
8955
8956
2/2
✓ Branch 0 taken 783342 times.
✓ Branch 1 taken 114198 times.
897540 for(int32_t i=0; i<guys.Count(); i++)
8957 {
8958
4/4
✓ Branch 0 taken 627294 times.
✓ Branch 1 taken 156048 times.
✓ Branch 2 taken 401598 times.
✓ Branch 3 taken 225696 times.
783342 if(guys.spr(i)->id==id && (((enemy*)guys.spr(i))->misc>=0))
8959 {
8960 225696 ++active;
8961 225696 }
8962 783342 }
8963
8964
2/2
✓ Branch 0 taken 112327 times.
✓ Branch 1 taken 1871 times.
114198 if(active<((dmisc1==2)?1:2))
8965 {
8966 1871 misc=0; //activate this one
8967 1871 clk3=1; //This needs to be set so that it knows that it's being emerged of its own will and not because it got stunned.
8968 1871 }
8969 }
8970 114198 break;
8971
8972 case 0:
8973 {
8974
8975
4/6
✓ Branch 0 taken 11920 times.
✓ Branch 1 taken 37189 times.
✓ Branch 2 taken 11920 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 11920 times.
49109 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk))
8976 {
8977 misc=1;
8978 clk2=0;
8979 }
8980
2/2
✓ Branch 0 taken 57 times.
✓ Branch 1 taken 49052 times.
49109 else if (clk3<=0)
8981 {
8982 57 misc = -1;
8983 57 break;
8984 }
8985 49052 int32_t s=0;
8986
8987
2/2
✓ Branch 0 taken 273250 times.
✓ Branch 1 taken 49052 times.
322302 for(int32_t i=0; i<guys.Count(); i++)
8988 {
8989
4/4
✓ Branch 0 taken 164314 times.
✓ Branch 1 taken 108936 times.
✓ Branch 2 taken 156432 times.
✓ Branch 3 taken 7882 times.
273250 if(guys.spr(i)->id==id && ((enemy*)guys.spr(i))->misc==1)
8990 {
8991 7882 ++s;
8992 7882 }
8993 273250 }
8994
8995
2/2
✓ Branch 0 taken 7882 times.
✓ Branch 1 taken 41170 times.
49052 if(s>0)
8996 {
8997 7882 break;
8998 }
8999
9000 41170 int32_t d2=zc_oldrand()&1;
9001
9002
2/2
✓ Branch 0 taken 14509 times.
✓ Branch 1 taken 26661 times.
41170 if(HeroDir()>=left)
9003 {
9004 26661 d2+=2;
9005 26661 }
9006
9007
4/4
✓ Branch 0 taken 39722 times.
✓ Branch 1 taken 1448 times.
✓ Branch 2 taken 662 times.
✓ Branch 3 taken 39060 times.
41170 if(canplace(d2) || canplace(d2^1))
9008 {
9009 2110 misc=1;
9010 2110 clk2=0;
9011 2110 clk=0;
9012 2110 }
9013 }
9014 41170 break;
9015
9016 case 1:
9017
9018
7/8
✓ Branch 0 taken 33397 times.
✓ Branch 1 taken 2067 times.
✓ Branch 2 taken 3596 times.
✓ Branch 3 taken 29801 times.
✓ Branch 4 taken 3596 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 3595 times.
35464 if(++clk2>16||(!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk) && clk2>8)) misc=2;
9019
9020 35464 break;
9021
9022 case 2:
9023
9024
7/8
✓ Branch 0 taken 13865 times.
✓ Branch 1 taken 1915 times.
✓ Branch 2 taken 1503 times.
✓ Branch 3 taken 12362 times.
✓ Branch 4 taken 1503 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 1502 times.
15780 if(++clk2>24||(!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk) && clk2>12)) misc=3;
9025
9026 15780 break;
9027
9028 // case 3: if(stunclk) break; if(scored) dir^=1; if(!canmove(dir,false)) misc=4; else move((zfix)(d->step/100.0)); break;
9029 case 3:
9030
9031
5/6
✓ Branch 0 taken 98195 times.
✓ Branch 1 taken 3589 times.
✓ Branch 2 taken 98195 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2727 times.
✓ Branch 5 taken 95468 times.
101784 if(stunclk || frozenclock || watch) break;
9032
9033
2/2
✓ Branch 0 taken 142 times.
✓ Branch 1 taken 95326 times.
95468 if(scored) dir^=1;
9034
9035
2/2
✓ Branch 0 taken 505 times.
✓ Branch 1 taken 94963 times.
95468 if(!canmove(dir,false)) misc=4;
9036 94963 else move(zslongToFix(dstep*100));
9037
9038 95468 break;
9039
9040 case 4:
9041
4/6
✓ Branch 0 taken 610 times.
✓ Branch 1 taken 3755 times.
✓ Branch 2 taken 610 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 610 times.
4365 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk)) misc = 2;
9042
2/2
✓ Branch 0 taken 3897 times.
✓ Branch 1 taken 468 times.
4365 if(--clk2<=16)
9043 {
9044 468 misc=5;
9045 468 clk=8;
9046 468 }
9047
9048 4365 break;
9049
9050 case 5:
9051
5/6
✓ Branch 0 taken 1010 times.
✓ Branch 1 taken 5897 times.
✓ Branch 2 taken 1010 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 1009 times.
6907 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk)) misc = 1;
9052
2/2
✓ Branch 0 taken 6497 times.
✓ Branch 1 taken 410 times.
6907 if(--clk2<=0) misc=((dmisc1==2)?-1:0);
9053
9054 6907 break;
9055 } // switch(misc)
9056
9057 337868 break;
9058
9059 default: //random
9060 // step=d->misc3/100.0;
9061
9062 473814 step=zslongToFix(dmisc3*100);
9063
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 473814 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
473814 if (get_qr(qr_LEEVERS_DONT_OBEY_STUN) || (!watch && !stunclk)) ++clk2;
9064 else if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk))
9065 {
9066 if (clk2 < 48) clk2+=2;
9067 if (clk2 >= 300) clk2-=2;
9068 }
9069
9070
2/2
✓ Branch 0 taken 60840 times.
✓ Branch 1 taken 412974 times.
473814 if(clk2<32) misc=1;
9071
2/2
✓ Branch 0 taken 30244 times.
✓ Branch 1 taken 382730 times.
412974 else if(clk2<48) misc=2;
9072
2/2
✓ Branch 0 taken 289541 times.
✓ Branch 1 taken 93189 times.
382730 else if(clk2<300)
9073 {
9074 /*if(misc==2 && (int32_t)(dmisc3*0.48)%8)
9075 {
9076 fix_coords();
9077 }*/
9078 289541 misc=3;
9079 289541 step = zslongToFix(dstep*100);
9080 289541 }
9081
2/2
✓ Branch 0 taken 9009 times.
✓ Branch 1 taken 84180 times.
93189 else if(clk2<316) misc=2;
9082
2/2
✓ Branch 0 taken 43755 times.
✓ Branch 1 taken 40425 times.
84180 else if(clk2<412) misc=1;
9083
2/2
✓ Branch 0 taken 40151 times.
✓ Branch 1 taken 274 times.
40425 else if(clk2<540)
9084 {
9085 40151 misc=0;
9086 40151 step=0;
9087 40151 }
9088 274 else clk2=0;
9089
9090
2/2
✓ Branch 0 taken 471961 times.
✓ Branch 1 taken 1853 times.
473814 if(clk2==48) clk=0;
9091
9092 // variable_walk(d->rate, d->homing, 0);
9093 473814 variable_walk(rate, homing, 0);
9094 473814 } // switch(dmisc1)
9095 811682 }
9096
9097 986571 hxofs=(misc>=2)?0:1000;
9098 986571 return enemy::animate(index);
9099 1018478 }
9100
9101 80892 bool eLeever::canplace(int32_t d2)
9102 {
9103 80892 int32_t nx=HeroX();
9104 80892 int32_t ny=HeroY();
9105
9106
2/2
✓ Branch 0 taken 28492 times.
✓ Branch 1 taken 52400 times.
80892 if(d2<left) ny&=0xF0;
9107 52400 else nx&=0xF0;
9108
9109
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 14174 times.
✓ Branch 2 taken 14318 times.
✓ Branch 3 taken 26181 times.
✓ Branch 4 taken 26219 times.
80892 switch(d2)
9110 {
9111 // case up: ny-=((d->misc1==0)?32:48); break;
9112 // case down: ny+=((d->misc1==0)?32:48); if(ny-HeroY()<32) ny+=((d->misc1==0)?16:0); break;
9113 // case left: nx-=((d->misc1==0)?32:48); break;
9114 // case right: nx+=((d->misc1==0)?32:48); if(nx-HeroX()<32) nx+=((d->misc1==0)?16:0); break;
9115 case up:
9116
2/2
✓ Branch 0 taken 14144 times.
✓ Branch 1 taken 30 times.
14174 ny-=((dmisc1==0||dmisc1==2)?32:48);
9117 14174 break;
9118
9119 case down:
9120
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 14284 times.
14318 ny+=((dmisc1==0||dmisc1==2)?32:48);
9121
9122
4/4
✓ Branch 0 taken 10086 times.
✓ Branch 1 taken 4232 times.
✓ Branch 2 taken 10075 times.
✓ Branch 3 taken 11 times.
14318 if(ny-HeroY()<32) ny+=((dmisc1==0||dmisc1==2)?16:0);
9123
9124 14318 break;
9125
9126 case left:
9127
2/2
✓ Branch 0 taken 25528 times.
✓ Branch 1 taken 653 times.
26181 nx-=((dmisc1==0||dmisc1==2)?32:48);
9128 26181 break;
9129
9130 case right:
9131
2/2
✓ Branch 0 taken 646 times.
✓ Branch 1 taken 25573 times.
26219 nx+=((dmisc1==0||dmisc1==2)?32:48);
9132
9133
4/4
✓ Branch 0 taken 19151 times.
✓ Branch 1 taken 7068 times.
✓ Branch 2 taken 18549 times.
✓ Branch 3 taken 602 times.
26219 if(nx-HeroX()<32) nx+=((dmisc1==0||dmisc1==2)?16:0);
9134
9135 26219 break;
9136 }
9137
9138
4/4
✓ Branch 0 taken 20428 times.
✓ Branch 1 taken 60464 times.
✓ Branch 2 taken 9001 times.
✓ Branch 3 taken 11427 times.
80892 if(m_walkflag(nx,ny,spw_halfstep, dir)||m_walkflag(nx,ny-8,spw_halfstep, dir)) /*none*/
9139 69465 return false;
9140
9141
2/2
✓ Branch 0 taken 864 times.
✓ Branch 1 taken 10563 times.
11427 if(d2>=left)
9142
4/4
✓ Branch 0 taken 5025 times.
✓ Branch 1 taken 5538 times.
✓ Branch 2 taken 9317 times.
✓ Branch 3 taken 1246 times.
10563 if(m_walkflag(HeroX(),HeroY(),spw_halfstep, dir)||m_walkflag(HeroX(),HeroY()-8,spw_halfstep, dir)) /*none*/
9143 9317 return false;
9144
9145 2110 x=nx;
9146 2110 y=ny;
9147 2110 dir=d2^1;
9148 2110 return true;
9149 80892 }
9150
9151 1024382 void eLeever::draw(BITMAP *dest)
9152 {
9153 // cs=d->cset;
9154 1024382 cs=dcset;
9155 1024382 update_enemy_frame();
9156
3/4
✓ Branch 0 taken 1024027 times.
✓ Branch 1 taken 355 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1024027 times.
1024382 if(!fallclk&&!drownclk)
9157 {
9158
2/2
✓ Branch 0 taken 637088 times.
✓ Branch 1 taken 386939 times.
1024027 switch(misc)
9159 {
9160 case -1:
9161 case 0:
9162 386939 return;
9163 }
9164 637088 }
9165
9166 637443 enemy::draw(dest);
9167 1024382 }
9168
9169 998 eWallM::eWallM(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9170 998 {
9171 998 hashero=false;
9172 //nets+1000;
9173
1/4
✓ Branch 0 taken 998 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
998 if (SIZEflags != 0) init_size_flags();;
9174 998 }
9175
9176 504762 bool eWallM::animate(int32_t index)
9177 {
9178
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 504762 times.
504762 if(switch_hooked) return enemy::animate(index);
9179
2/4
✓ Branch 0 taken 504762 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 504762 times.
504762 if(fallclk||drownclk)
9180 {
9181 return enemy::animate(index);
9182 }
9183
2/2
✓ Branch 0 taken 9856 times.
✓ Branch 1 taken 494906 times.
504762 if(dying)
9184 9856 return Dead(index);
9185
9186
2/2
✓ Branch 0 taken 463930 times.
✓ Branch 1 taken 30976 times.
494906 if(clk==0)
9187 {
9188 30976 removearmos(x,y,ffcactivated);
9189 30976 }
9190
9191 494906 hxofs=1000;
9192
2/2
✓ Branch 0 taken 117732 times.
✓ Branch 1 taken 377174 times.
494906 if(misc==0) //inside wall, ready to spawn?
9193 {
9194
4/4
✓ Branch 0 taken 228512 times.
✓ Branch 1 taken 148662 times.
✓ Branch 2 taken 16723 times.
✓ Branch 3 taken 211789 times.
377174 if(frame-wallm_load_clk>80 && clk>=0)
9195 {
9196 211789 int32_t wall=hero_on_wall();
9197 211789 int32_t wallm_cnt=0;
9198
9199
2/2
✓ Branch 0 taken 1670618 times.
✓ Branch 1 taken 211789 times.
1882407 for(int32_t i=0; i<guys.Count(); i++)
9200
2/2
✓ Branch 0 taken 657527 times.
✓ Branch 1 taken 1013091 times.
2683709 if(((enemy*)guys.spr(i))->family==eeWALLM)
9201 {
9202 1013091 int32_t m=((enemy*)guys.spr(i))->misc;
9203
9204
4/4
✓ Branch 0 taken 50104 times.
✓ Branch 1 taken 962987 times.
✓ Branch 2 taken 36738 times.
✓ Branch 3 taken 13366 times.
1013091 if(m && ((enemy*)guys.spr(i))->clk3==(wall^1))
9205 {
9206 13366 ++wallm_cnt;
9207 13366 }
9208 1013091 }
9209
9210
2/2
✓ Branch 0 taken 210948 times.
✓ Branch 1 taken 841 times.
211789 if(wall>0)
9211 {
9212 841 --wall;
9213 841 misc=1; //emerging from the wall?
9214 841 clk2=0;
9215 841 clk3=wall^1;
9216 841 wallm_load_clk=frame;
9217
9218
2/2
✓ Branch 0 taken 514 times.
✓ Branch 1 taken 327 times.
841 if(wall<=down)
9219 {
9220
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 423 times.
514 if(HeroDir()==left)
9221 91 dir=right;
9222 else
9223 423 dir=left;
9224 514 }
9225 else
9226 {
9227
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 261 times.
327 if(HeroDir()==up)
9228 66 dir=down;
9229 else
9230 261 dir=up;
9231 }
9232
9233
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 231 times.
✓ Branch 2 taken 283 times.
✓ Branch 3 taken 223 times.
✓ Branch 4 taken 104 times.
841 switch(wall)
9234 {
9235 case up:
9236 231 y=0;
9237 231 break;
9238
9239 case down:
9240 283 y=160;
9241 283 break;
9242
9243 case left:
9244 223 x=0;
9245 223 break;
9246
9247 case right:
9248 104 x=240;
9249 104 break;
9250 }
9251
9252
9253
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 261 times.
✓ Branch 2 taken 66 times.
✓ Branch 3 taken 423 times.
✓ Branch 4 taken 91 times.
841 switch(dir)
9254 {
9255 case up:
9256 261 y=(HeroY()+48-(wallm_cnt&1)*12);
9257 261 flip=wall&1;
9258 261 break;
9259
9260 case down:
9261 66 y=(HeroY()-48+(wallm_cnt&1)*12);
9262 66 flip=((wall&1)^1)+2;
9263 66 break;
9264
9265 case left:
9266 423 x=(HeroX()+48-(wallm_cnt&1)*12);
9267 423 flip=(wall==up?2:0)+1;
9268 423 break;
9269
9270 case right:
9271 91 x=(HeroX()-48+(wallm_cnt&1)*12);
9272 91 flip=(wall==up?2:0);
9273 91 break;
9274 }
9275
9276 841 }
9277 211789 }
9278 377174 }
9279 else
9280 117732 wallm_crawl();
9281
9282 494906 return enemy::animate(index);
9283 504762 }
9284
9285 117732 void eWallM::wallm_crawl()
9286 {
9287 117732 bool w=watch;
9288 117732 hxofs=0;
9289
9290
2/2
✓ Branch 0 taken 810 times.
✓ Branch 1 taken 116922 times.
117732 if(slide())
9291 {
9292 810 return;
9293 }
9294
9295 // if(dying || watch || (!hashero && stunclk))
9296
6/8
✓ Branch 0 taken 116922 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115593 times.
✓ Branch 3 taken 1329 times.
✓ Branch 4 taken 101047 times.
✓ Branch 5 taken 14546 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 101047 times.
116922 if(dying || (!hashero && ( stunclk || frozenclock )))
9297 {
9298 14546 return;
9299 }
9300
9301 102376 watch=false;
9302 102376 ++clk2;
9303 // Misc1: slightly different movement
9304 102376 float tmpmisc3 = ((40.0/(int32_t)dstep)*40);
9305
9306 //int32_t tmpmisc = int32_t((40.0/dstep)*40);
9307
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102376 times.
102376 misc=(clk2/(dmisc1==1?40:(int32_t)tmpmisc3))+1;
9308
5/6
✓ Branch 0 taken 6217 times.
✓ Branch 1 taken 96159 times.
✓ Branch 2 taken 4491 times.
✓ Branch 3 taken 1726 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4491 times.
102376 if(w&&misc>=3&&misc<=5)
9309 {
9310 4491 --clk2;
9311 4491 }
9312
9313
4/4
✓ Branch 0 taken 39396 times.
✓ Branch 1 taken 52852 times.
✓ Branch 2 taken 9984 times.
✓ Branch 3 taken 144 times.
102376 switch(misc)
9314 {
9315 case 1:
9316 case 2:
9317 52852 zc_swap(dir,clk3);
9318 52852 move(step);
9319 52852 zc_swap(dir,clk3);
9320 52852 break;
9321
9322 case 3:
9323 case 4:
9324 case 5:
9325
2/2
✓ Branch 0 taken 4491 times.
✓ Branch 1 taken 34905 times.
39396 if(w)
9326 {
9327 4491 watch=w;
9328 4491 return;
9329 }
9330
9331 34905 move(step);
9332 34905 break;
9333
9334 case 6:
9335 case 7:
9336 9984 zc_swap(dir,clk3);
9337 9984 dir^=1;
9338 9984 move(step);
9339 9984 dir^=1;
9340 9984 zc_swap(dir,clk3);
9341 9984 break;
9342
9343 default:
9344 144 misc=0;
9345 144 break;
9346 }
9347
9348 97885 watch=w;
9349 117732 }
9350
9351 9 void eWallM::grabhero()
9352 {
9353 9 hashero=true;
9354 9 superman=1;
9355 9 }
9356
9357 507147 void eWallM::draw(BITMAP *dest)
9358 {
9359 507147 dummy_bool[1]=hashero;
9360 507147 update_enemy_frame();
9361
9362
4/6
✓ Branch 0 taken 377966 times.
✓ Branch 1 taken 129181 times.
✓ Branch 2 taken 377966 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 377966 times.
507147 if(misc>0 || fallclk||drownclk)
9363 {
9364 129181 masked_draw(dest,16,playing_field_offset+16,224,144);
9365 129181 }
9366
9367 // enemy::draw(dest);
9368 // tile = clk&8 ? 128:129;
9369 507147 }
9370
9371 bool eWallM::isSubmerged() const
9372 {
9373 return ( !misc );
9374 }
9375
9376 1600 eTrap::eTrap(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9377 1600 {
9378
1/2
✓ Branch 0 taken 1600 times.
✗ Branch 1 not taken.
1600 ox=x; //original x
9379
1/2
✓ Branch 0 taken 1600 times.
✗ Branch 1 not taken.
1600 oy=y; //original y
9380
2/2
✓ Branch 0 taken 1474 times.
✓ Branch 1 taken 126 times.
1600 if(get_qr(qr_TRAPPOSFIX))
9381 {
9382
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
126 yofs = (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
9383 126 }
9384
9385 1600 mainguy=false;
9386
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1600 times.
1600 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
9387 //nets+420;
9388 1600 dummy_int[1]=0;
9389
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1600 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1600 if (SIZEflags != 0) init_size_flags();;
9390 1600 }
9391
9392 1036935 bool eTrap::animate(int32_t index)
9393 {
9394
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1036935 times.
1036935 if(switch_hooked) return enemy::animate(index);
9395
2/4
✓ Branch 0 taken 1036935 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1036935 times.
1036935 if(fallclk||drownclk) return enemy::animate(index);
9396
2/2
✓ Branch 0 taken 1015341 times.
✓ Branch 1 taken 21594 times.
1036935 if(clk<0)
9397 21594 return enemy::animate(index);
9398
9399
2/2
✓ Branch 0 taken 951124 times.
✓ Branch 1 taken 64217 times.
1015341 if(clk==0)
9400 {
9401 64217 removearmos(x,y,ffcactivated);
9402 64217 }
9403
9404
2/2
✓ Branch 0 taken 317997 times.
✓ Branch 1 taken 697344 times.
1015341 if(misc==0) // waiting
9405 {
9406 697344 ox = x;
9407 697344 oy = y;
9408 double _MSVC2022_tmp1, _MSVC2022_tmp2;
9409 697344 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
9410
9411
4/4
✓ Branch 0 taken 240663 times.
✓ Branch 1 taken 456681 times.
✓ Branch 2 taken 133176 times.
✓ Branch 3 taken 107487 times.
697344 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
9412 {
9413 107487 dir=down;
9414 107487 }
9415
4/4
✓ Branch 0 taken 391518 times.
✓ Branch 1 taken 198339 times.
✓ Branch 2 taken 133176 times.
✓ Branch 3 taken 258342 times.
589857 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
9416 {
9417 258342 dir=right;
9418 258342 }
9419
4/4
✓ Branch 0 taken 210645 times.
✓ Branch 1 taken 120870 times.
✓ Branch 2 taken 133176 times.
✓ Branch 3 taken 77469 times.
331515 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/4)))
9420 {
9421 77469 dir=up;
9422 77469 }
9423 else
9424 {
9425 254046 dir=left;
9426 }
9427
9428 697344 int32_t d2=lined_up(15,true);
9429
9430
4/4
✓ Branch 0 taken 267045 times.
✓ Branch 1 taken 430299 times.
✓ Branch 2 taken 1111152 times.
✓ Branch 3 taken 413808 times.
1091329 if(((d2<left || d2 > right) && (dmisc1==1)) ||
9431
2/2
✓ Branch 0 taken 232556 times.
✓ Branch 1 taken 190596 times.
413808 ((d2>down) && (dmisc1==2)) ||
9432
2/2
✓ Branch 0 taken 187069 times.
✓ Branch 1 taken 60611 times.
190596 ((d2>right) && (!dmisc1)) ||
9433
2/2
✓ Branch 0 taken 393985 times.
✓ Branch 1 taken 146305 times.
247680 ((d2<l_up) && (dmisc1==4)) ||
9434
3/4
✓ Branch 0 taken 393985 times.
✓ Branch 1 taken 247680 times.
✓ Branch 2 taken 393985 times.
✗ Branch 3 not taken.
146305 ((d2!=r_up) && (d2!=l_down) && (dmisc1==6)) ||
9435
3/4
✓ Branch 0 taken 393985 times.
✓ Branch 1 taken 146305 times.
✓ Branch 2 taken 393985 times.
✗ Branch 3 not taken.
247680 ((d2!=l_up) && (d2!=r_down) && (dmisc1==8)))
9436 {
9437 2525663 d2=-1;
9438 2525663 }
9439
9440
4/4
✓ Branch 0 taken 20700 times.
✓ Branch 1 taken 428964 times.
✓ Branch 2 taken 18593 times.
✓ Branch 3 taken 2107 times.
449664 if(d2!=-1 && trapmove(d2))
9441 {
9442 2107 dir=d2;
9443 2107 misc=1;
9444 2107 clk2=(dir==down)?3:0;
9445 2107 }
9446 449664 }
9447
9448
2/2
✓ Branch 0 taken 678404 times.
✓ Branch 1 taken 89257 times.
767661 if(misc==1) // charging
9449 {
9450 89257 clk2=(clk2+1)&3;
9451 89257 step=(clk2==3)?1:2;
9452
9453
4/4
✓ Branch 0 taken 88461 times.
✓ Branch 1 taken 796 times.
✓ Branch 2 taken 1105 times.
✓ Branch 3 taken 87356 times.
89257 if(!trapmove(dir) || clip())
9454 {
9455 1901 misc=2;
9456
9457
1/2
✓ Branch 0 taken 1901 times.
✗ Branch 1 not taken.
1901 if(dir<l_up)
9458 {
9459 1901 dir=dir^1;
9460 1901 }
9461 else
9462 {
9463 dir=dir^3;
9464 }
9465 1901 }
9466 else
9467 {
9468 87356 sprite::move(step);
9469 }
9470 89257 }
9471
9472
2/2
✓ Branch 0 taken 534913 times.
✓ Branch 1 taken 232748 times.
767661 if(misc==2) // retreating
9473 {
9474 232748 step=(++clk2&1)?1:0;
9475
9476
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 39011 times.
✓ Branch 2 taken 80505 times.
✓ Branch 3 taken 29129 times.
✓ Branch 4 taken 84103 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
232748 switch(dir)
9477 {
9478 case up:
9479
2/2
✓ Branch 0 taken 272 times.
✓ Branch 1 taken 38739 times.
39011 if(int32_t(y)<=oy) goto trap_rest;
9480 38739 else sprite::move(step);
9481
9482 38739 break;
9483
9484 case left:
9485
2/2
✓ Branch 0 taken 388 times.
✓ Branch 1 taken 80117 times.
80505 if(int32_t(x)<=ox) goto trap_rest;
9486 80117 else sprite::move(step);
9487
9488 80117 break;
9489
9490 case down:
9491
2/2
✓ Branch 0 taken 224 times.
✓ Branch 1 taken 28905 times.
29129 if(int32_t(y)>=oy) goto trap_rest;
9492 28905 else sprite::move(step);
9493
9494 28905 break;
9495
9496 case right:
9497
2/2
✓ Branch 0 taken 431 times.
✓ Branch 1 taken 83672 times.
84103 if(int32_t(x)>=ox) goto trap_rest;
9498 83672 else sprite::move(step);
9499
9500 83672 break;
9501
9502 case l_up:
9503 if(int32_t(x)<=ox && int32_t(y)<=oy) goto trap_rest;
9504 else sprite::move(step);
9505
9506 break;
9507
9508 case r_up:
9509 if(int32_t(x)>=ox && int32_t(y)<=oy) goto trap_rest;
9510 else sprite::move(step);
9511
9512 break;
9513
9514 case l_down:
9515 if(int32_t(x)<=ox && int32_t(y)>=oy) goto trap_rest;
9516 else sprite::move(step);
9517
9518 break;
9519
9520 case r_down:
9521 if(int32_t(x)>=ox && int32_t(y)>=oy) goto trap_rest;
9522 else sprite::move(step);
9523
9524 break;
9525 trap_rest:
9526 {
9527 1315 x=ox;
9528 1315 y=oy;
9529 1315 misc=0;
9530 }
9531 1315 }
9532 232748 }
9533
9534 767661 return enemy::animate(index);
9535 789255 }
9536
9537 109957 bool eTrap::trapmove(int32_t ndir)
9538 {
9539
2/2
✓ Branch 0 taken 80193 times.
✓ Branch 1 taken 29764 times.
109957 if(get_qr(qr_MEANTRAPS))
9540 {
9541
2/2
✓ Branch 0 taken 1340 times.
✓ Branch 1 taken 78853 times.
80193 if(tmpscr->flags2&fFLOATTRAPS)
9542 1340 return canmove(ndir,(zfix)1,spw_floater, 0, 0, 15, 15,false);
9543
9544 78853 return canmove(ndir,(zfix)1,spw_water, 0, 0, 15, 15,false);
9545 }
9546
9547
6/6
✓ Branch 0 taken 14672 times.
✓ Branch 1 taken 15092 times.
✓ Branch 2 taken 7198 times.
✓ Branch 3 taken 7474 times.
✓ Branch 4 taken 2468 times.
✓ Branch 5 taken 4730 times.
29764 if(oy==80 && !(ndir==left || ndir == right))
9548 4730 return false;
9549
9550
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 25034 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
25034 if(ox==128 && !(ndir==up || ndir==down))
9551 return false;
9552
9553
3/4
✓ Branch 0 taken 7496 times.
✓ Branch 1 taken 17538 times.
✓ Branch 2 taken 7496 times.
✗ Branch 3 not taken.
25034 if(oy<80 && ndir==up)
9554 return false;
9555
9556
3/4
✓ Branch 0 taken 7596 times.
✓ Branch 1 taken 17438 times.
✓ Branch 2 taken 7596 times.
✗ Branch 3 not taken.
25034 if(oy>80 && ndir==down)
9557 return false;
9558
9559
4/4
✓ Branch 0 taken 14455 times.
✓ Branch 1 taken 10579 times.
✓ Branch 2 taken 9733 times.
✓ Branch 3 taken 4722 times.
25034 if(ox<128 && ndir==left)
9560 4722 return false;
9561
9562
4/4
✓ Branch 0 taken 10579 times.
✓ Branch 1 taken 9733 times.
✓ Branch 2 taken 9866 times.
✓ Branch 3 taken 713 times.
20312 if(ox>128 && ndir==right)
9563 713 return false;
9564
9565
5/6
✓ Branch 0 taken 9733 times.
✓ Branch 1 taken 9866 times.
✓ Branch 2 taken 4067 times.
✓ Branch 3 taken 5666 times.
✓ Branch 4 taken 4067 times.
✗ Branch 5 not taken.
19599 if(ox<128 && oy<80 && ndir==l_up)
9566 return false;
9567
9568
5/6
✓ Branch 0 taken 9733 times.
✓ Branch 1 taken 9866 times.
✓ Branch 2 taken 3911 times.
✓ Branch 3 taken 5822 times.
✓ Branch 4 taken 3911 times.
✗ Branch 5 not taken.
19599 if(ox<128 && oy>80 && ndir==l_down)
9569 return false;
9570
9571
5/6
✓ Branch 0 taken 9866 times.
✓ Branch 1 taken 9733 times.
✓ Branch 2 taken 3429 times.
✓ Branch 3 taken 6437 times.
✓ Branch 4 taken 3429 times.
✗ Branch 5 not taken.
19599 if(ox>128 && oy<80 && ndir==r_up)
9572 return false;
9573
9574
5/6
✓ Branch 0 taken 9866 times.
✓ Branch 1 taken 9733 times.
✓ Branch 2 taken 3685 times.
✓ Branch 3 taken 6181 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3685 times.
19599 if(ox>128 && oy>80 && ndir==r_down)
9575 return false;
9576
9577 19599 return true;
9578 109957 }
9579
9580 88461 bool eTrap::clip()
9581 {
9582
2/2
✓ Branch 0 taken 43022 times.
✓ Branch 1 taken 45439 times.
88461 if(get_qr(qr_MEANPLACEDTRAPS))
9583 {
9584
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 5792 times.
✓ Branch 2 taken 8656 times.
✓ Branch 3 taken 15895 times.
✓ Branch 4 taken 15096 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
45439 switch(dir)
9585 {
9586 case up:
9587
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5792 times.
5792 if(y<=0) return true;
9588
9589 5792 break;
9590
9591 case down:
9592
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8656 times.
8656 if(y>=160) return true;
9593
9594 8656 break;
9595
9596 case left:
9597
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15895 times.
15895 if(x<=0) return true;
9598
9599 15895 break;
9600
9601 case right:
9602
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15096 times.
15096 if(x>=240) return true;
9603
9604 15096 break;
9605
9606 case l_up:
9607 if(y<=0||x<=0) return true;
9608
9609 break;
9610
9611 case l_down:
9612 if(y>=160||x<=0) return true;
9613
9614 break;
9615
9616 case r_up:
9617 if(y<=0||x>=240) return true;
9618
9619 break;
9620
9621 case r_down:
9622 if(y>=160||x>=240) return true;
9623
9624 break;
9625 }
9626
9627 45439 return false;
9628 }
9629 else
9630 {
9631
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 4882 times.
✓ Branch 2 taken 5449 times.
✓ Branch 3 taken 16755 times.
✓ Branch 4 taken 15936 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
43022 switch(dir)
9632 {
9633 case up:
9634
4/4
✓ Branch 0 taken 4828 times.
✓ Branch 1 taken 54 times.
✓ Branch 2 taken 4641 times.
✓ Branch 3 taken 187 times.
4882 if(oy>80 && y<=86) return true;
9635
9636 4695 break;
9637
9638 case down:
9639
4/4
✓ Branch 0 taken 5368 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 5172 times.
✓ Branch 3 taken 196 times.
5449 if(oy<80 && y>=80) return true;
9640
9641 5253 break;
9642
9643 case left:
9644
4/4
✓ Branch 0 taken 16665 times.
✓ Branch 1 taken 90 times.
✓ Branch 2 taken 16286 times.
✓ Branch 3 taken 379 times.
16755 if(ox>128 && x<=124) return true;
9645
9646 16376 break;
9647
9648 case right:
9649
4/4
✓ Branch 0 taken 15855 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 15512 times.
✓ Branch 3 taken 343 times.
15936 if(ox<120 && x>=116) return true;
9650
9651 15593 break;
9652
9653 case l_up:
9654 if(oy>80 && y<=86 && ox>128 && x<=124) return true;
9655
9656 break;
9657
9658 case l_down:
9659 if(oy<80 && y>=80 && ox>128 && x<=124) return true;
9660
9661 break;
9662
9663 case r_up:
9664 if(oy>80 && y<=86 && ox<120 && x>=116) return true;
9665
9666 break;
9667
9668 case r_down:
9669 if(oy<80 && y>=80 && ox<120 && x>=116) return true;
9670
9671 break;
9672 }
9673
9674 41917 return false;
9675 }
9676 88461 }
9677
9678 1043991 void eTrap::draw(BITMAP *dest)
9679 {
9680 1043991 update_enemy_frame();
9681 1043991 enemy::draw(dest);
9682 1043991 }
9683
9684 5705 int32_t eTrap::takehit(weapon*,weapon*)
9685 {
9686 5705 return 0;
9687 }
9688
9689 832 eTrap2::eTrap2(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9690 832 {
9691 832 lasthit=-1;
9692 832 lasthitclk=0;
9693 832 mainguy=false;
9694
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
832 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
9695
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 step=2;
9696
3/6
✓ Branch 0 taken 433 times.
✓ Branch 1 taken 399 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 433 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
832 if(dmisc1==1 || (dmisc1==0 && zc_oldrand()&2))
9697 {
9698
2/4
✓ Branch 0 taken 399 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 399 times.
✗ Branch 3 not taken.
399 dir=(x<=112)?right:left;
9699 399 }
9700 else
9701 {
9702
2/4
✓ Branch 0 taken 433 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 433 times.
✗ Branch 3 not taken.
433 dir=(y<=72)?down:up;
9703 }
9704
9705
2/2
✓ Branch 0 taken 760 times.
✓ Branch 1 taken 72 times.
832 if(get_qr(qr_TRAPPOSFIX))
9706 {
9707
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
✓ Branch 2 taken 72 times.
✗ Branch 3 not taken.
72 yofs = (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
9708 72 }
9709
9710 //nets+((id==eTRAP_LR)?540:520);
9711 832 dummy_int[1]=0;
9712
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
832 if (SIZEflags != 0) init_size_flags();;
9713 832 }
9714
9715 346559 bool eTrap2::animate(int32_t index)
9716 {
9717
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 346559 times.
346559 if(switch_hooked) return enemy::animate(index);
9718
2/4
✓ Branch 0 taken 346559 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 346559 times.
346559 if(fallclk||drownclk) return enemy::animate(index);
9719
2/2
✓ Branch 0 taken 335533 times.
✓ Branch 1 taken 11026 times.
346559 if(clk<0)
9720 11026 return enemy::animate(index);
9721
9722
2/2
✓ Branch 0 taken 21385 times.
✓ Branch 1 taken 314148 times.
335533 if(clk==0)
9723 {
9724 21385 removearmos(x,y,ffcactivated);
9725 21385 }
9726
9727
2/2
✓ Branch 0 taken 211207 times.
✓ Branch 1 taken 124326 times.
335533 if(!get_qr(qr_PHANTOMPLACEDTRAPS))
9728 {
9729
2/2
✓ Branch 0 taken 11074 times.
✓ Branch 1 taken 113252 times.
124326 if(lasthitclk>0)
9730 {
9731 11074 --lasthitclk;
9732 11074 }
9733 else
9734 {
9735 113252 lasthit=-1;
9736 }
9737
9738 124326 bool hitenemy=false;
9739
9740
2/2
✓ Branch 0 taken 864860 times.
✓ Branch 1 taken 124326 times.
989186 for(int32_t j=0; j<guys.Count(); j++)
9741 {
9742
4/4
✓ Branch 0 taken 740534 times.
✓ Branch 1 taken 124326 times.
✓ Branch 2 taken 10183 times.
✓ Branch 3 taken 730351 times.
864860 if((j!=index) && (lasthit!=j))
9743 {
9744
2/2
✓ Branch 0 taken 726682 times.
✓ Branch 1 taken 3669 times.
730351 if(hit(guys.spr(j)))
9745 {
9746 3669 lasthit=j;
9747 3669 lasthitclk=10;
9748 3669 hitenemy=true;
9749 3669 guys.spr(j)->lasthit=index;
9750 3669 guys.spr(j)->lasthitclk=10;
9751 // guys.spr(j)->dir=guys.spr(j)->dir^1;
9752 3669 }
9753 730351 }
9754 864860 }
9755
9756
5/6
✓ Branch 0 taken 121171 times.
✓ Branch 1 taken 3155 times.
✓ Branch 2 taken 121171 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2831 times.
✓ Branch 5 taken 118340 times.
124326 if(!trapmove(dir) || clip() || hitenemy)
9757 {
9758
3/4
✓ Branch 0 taken 2831 times.
✓ Branch 1 taken 3155 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2831 times.
5986 if(!trapmove(dir) || clip())
9759 {
9760 3155 lasthit=-1;
9761 3155 lasthitclk=0;
9762 3155 }
9763
9764
2/2
✓ Branch 0 taken 5624 times.
✓ Branch 1 taken 362 times.
5986 if(get_qr(qr_MORESOUNDS))
9765 362 sfx(WAV_ZN1TAP,pan(int32_t(x)));
9766
9767 5986 dir=dir^1;
9768 5986 }
9769
9770 124326 sprite::move(step);
9771 124326 }
9772 else
9773 {
9774
3/4
✓ Branch 0 taken 204288 times.
✓ Branch 1 taken 6919 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 204288 times.
211207 if(!trapmove(dir) || clip())
9775 {
9776
2/2
✓ Branch 0 taken 5398 times.
✓ Branch 1 taken 1521 times.
6919 if(get_qr(qr_MORESOUNDS))
9777 1521 sfx(WAV_ZN1TAP,pan(int32_t(x)));
9778
9779 6919 dir=dir^1;
9780 6919 }
9781
9782 211207 sprite::move(step);
9783 }
9784
9785 335533 return enemy::animate(index);
9786 346559 }
9787
9788 341519 bool eTrap2::trapmove(int32_t ndir)
9789 {
9790
2/2
✓ Branch 0 taken 1878 times.
✓ Branch 1 taken 339641 times.
341519 if(tmpscr->flags2&fFLOATTRAPS)
9791 1878 return canmove(ndir,(zfix)1,spw_floater, 0, 0, 15, 15,false);
9792
9793 339641 return canmove(ndir,(zfix)1,spw_water, 0, 0, 15, 15,false);
9794 341519 }
9795
9796 328290 bool eTrap2::clip()
9797 {
9798
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 88320 times.
✓ Branch 2 taken 89029 times.
✓ Branch 3 taken 75153 times.
✓ Branch 4 taken 75788 times.
328290 switch(dir)
9799 {
9800 case up:
9801
1/2
✓ Branch 0 taken 88320 times.
✗ Branch 1 not taken.
88320 if(y<=0) return true;
9802
9803 88320 break;
9804
9805 case down:
9806
1/2
✓ Branch 0 taken 89029 times.
✗ Branch 1 not taken.
89029 if(y>=160) return true;
9807
9808 89029 break;
9809
9810 case left:
9811
1/2
✓ Branch 0 taken 75153 times.
✗ Branch 1 not taken.
75153 if(x<=0) return true;
9812
9813 75153 break;
9814
9815 case right:
9816
1/2
✓ Branch 0 taken 75788 times.
✗ Branch 1 not taken.
75788 if(x>=240) return true;
9817
9818 75788 break;
9819 }
9820
9821 328290 return false;
9822 328290 }
9823
9824 350933 void eTrap2::draw(BITMAP *dest)
9825 {
9826 350933 update_enemy_frame();
9827 350933 enemy::draw(dest);
9828 350933 }
9829
9830 3169 int32_t eTrap2::takehit(weapon*,weapon*)
9831 {
9832 3169 return 0;
9833 }
9834
9835 354 eRock::eRock(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9836 354 {
9837 //do not show "enemy appering" anim -DD
9838 354 clk=0;
9839 354 mainguy=false;
9840 354 clk2=-14;
9841 //Enemy Editor Size Tab
9842
1/2
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
354 init_size_flags();
9843 //nets+1640;
9844 354 }
9845
9846 354 void eRock::init_size_flags()
9847 {
9848
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
354 if ((d->SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
9849 354 else hxofs = -2;
9850
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
354 if ((d->SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
9851 354 else hyofs = -2;
9852
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
354 if (((d->SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0) hit_width = d->hxsz;
9853 354 else hit_width = 20;
9854
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
354 if (((d->SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0) hit_height = d->hysz;
9855 354 else hit_height = 20;
9856
9857
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
354 if (((d->SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
9858
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
354 if (((d->SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
9859
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
354 if (((d->SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0) hzsz = d->hzsz;
9860
1/2
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
354 if ((d->SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)d->xofs;
9861
1/2
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
354 if ((d->SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
9862 {
9863 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
9864 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
9865 }
9866
9867
1/2
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
354 if ((d->SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)d->zofs;
9868 354 }
9869
9870 121997 bool eRock::animate(int32_t index)
9871 {
9872
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 121997 times.
121997 if(switch_hooked) return enemy::animate(index);
9873
2/4
✓ Branch 0 taken 121997 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 121997 times.
121997 if(fallclk||drownclk) return enemy::animate(index);
9874
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 121997 times.
121997 if(dying)
9875 return Dead(index);
9876
9877
2/2
✓ Branch 0 taken 113621 times.
✓ Branch 1 taken 8376 times.
121997 if(clk==0)
9878 {
9879 8376 removearmos(x,y,ffcactivated);
9880 8376 }
9881
9882
2/2
✓ Branch 0 taken 121300 times.
✓ Branch 1 taken 697 times.
121997 if(++clk2==0) // start it
9883 {
9884 697 x=zc_oldrand()&0xF0;
9885 697 y=0;
9886 697 clk3=0;
9887 697 clk2=zc_oldrand()&15;
9888 697 }
9889
9890
2/2
✓ Branch 0 taken 22820 times.
✓ Branch 1 taken 99177 times.
121997 if(clk2>16) // move it
9891 {
9892
2/2
✓ Branch 0 taken 95747 times.
✓ Branch 1 taken 3430 times.
99177 if(clk3<=0) // start bounce
9893 {
9894 3430 dir=zc_oldrand()&1;
9895
9896
2/2
✓ Branch 0 taken 3063 times.
✓ Branch 1 taken 367 times.
3430 if(x<32) dir=1;
9897
9898
2/2
✓ Branch 0 taken 3133 times.
✓ Branch 1 taken 297 times.
3430 if(x>208) dir=0;
9899 3430 }
9900
9901
2/2
✓ Branch 0 taken 95993 times.
✓ Branch 1 taken 3184 times.
99177 if(clk3<13+16)
9902 {
9903 95993 x += dir ? 1 : -1; //right, left
9904 95993 dummy_int[1]=dir;
9905
9906
2/2
✓ Branch 0 taken 6852 times.
✓ Branch 1 taken 89141 times.
95993 if(clk3<2)
9907 {
9908 6852 y-=2; //up
9909 6852 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
9910 6852 }
9911
2/2
✓ Branch 0 taken 10208 times.
✓ Branch 1 taken 78933 times.
89141 else if(clk3<5)
9912 {
9913 10208 y--; //up
9914 10208 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
9915 10208 }
9916
2/2
✓ Branch 0 taken 10135 times.
✓ Branch 1 taken 68798 times.
78933 else if(clk3<8)
9917 {
9918 10135 dummy_int[2]=(dummy_int[1]==1)?right:left;
9919 10135 }
9920
2/2
✓ Branch 0 taken 10058 times.
✓ Branch 1 taken 58740 times.
68798 else if(clk3<11)
9921 {
9922 10058 y++; //down
9923 10058 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
9924 10058 }
9925 else
9926 {
9927 58740 y+=2; //down
9928 58740 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
9929 }
9930
9931 95993 ++clk3;
9932 95993 }
9933
2/2
✓ Branch 0 taken 2761 times.
✓ Branch 1 taken 423 times.
3184 else if(y<176)
9934 2761 clk3=0; // next bounce
9935 else
9936 423 clk2 = -(zc_oldrand()&63); // back to top
9937 99177 }
9938
9939 121997 return enemy::animate(index);
9940 121997 }
9941
9942 51441 void eRock::drawshadow(BITMAP *dest, bool translucent)
9943 {
9944
2/2
✓ Branch 0 taken 7191 times.
✓ Branch 1 taken 44250 times.
51441 if(clk2>=0)
9945 {
9946 44250 int32_t tempy=yofs;
9947 44250 flip = 0;
9948 44250 int32_t fdiv = frate/4;
9949
1/2
✓ Branch 0 taken 44250 times.
✗ Branch 1 not taken.
44250 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
9950
1/2
✓ Branch 0 taken 44250 times.
✗ Branch 1 not taken.
44250 int32_t f2=get_qr(qr_NEWENEMYTILES)?
9951 44250 efrate:((clk>=(frate>>1))?1:0);
9952 44250 shadowtile = wpnsbuf[spr_shadow].tile+f2;
9953
9954 44250 yofs+=8;
9955
6/6
✓ Branch 0 taken 20474 times.
✓ Branch 1 taken 23776 times.
✓ Branch 2 taken 38962 times.
✓ Branch 3 taken 5288 times.
✓ Branch 4 taken 19073 times.
✓ Branch 5 taken 19889 times.
44250 yofs+=zc_max(0,zc_min(29-clk3,clk3));
9956
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44250 times.
44250 if(!shadow_overpit(this))
9957 44250 sprite::drawshadow(dest, translucent);
9958 44250 yofs=tempy;
9959 44250 }
9960 51441 }
9961
9962 122078 void eRock::draw(BITMAP *dest)
9963 {
9964
4/6
✓ Branch 0 taken 17035 times.
✓ Branch 1 taken 105043 times.
✓ Branch 2 taken 17035 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 17035 times.
122078 if(clk2>=0 || fallclk||drownclk)
9965 {
9966 105043 int32_t tempdir=dir;
9967 105043 dir=dummy_int[2];
9968 105043 update_enemy_frame();
9969 105043 enemy::draw(dest);
9970 105043 dir=tempdir;
9971 105043 }
9972 122078 }
9973
9974 1014 int32_t eRock::takehit(weapon*,weapon*)
9975 {
9976 1014 return 0;
9977 }
9978
9979 30 eBoulder::eBoulder(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9980 30 {
9981 30 clk=0;
9982 30 mainguy=false;
9983 30 clk2=-14;
9984
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 init_size_flags();
9985 //nets+1680;
9986 30 }
9987
9988 4440 bool eBoulder::animate(int32_t index)
9989 {
9990
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4440 times.
4440 if(switch_hooked) return enemy::animate(index);
9991
2/4
✓ Branch 0 taken 4440 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4440 times.
4440 if(fallclk||drownclk) return enemy::animate(index);
9992
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4440 times.
4440 if(dying)
9993 return Dead(index);
9994
9995
2/2
✓ Branch 0 taken 4150 times.
✓ Branch 1 taken 290 times.
4440 if(clk==0)
9996 {
9997 290 removearmos(x,y,ffcactivated);
9998 290 }
9999
10000 zfix *vert;
10001
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4440 times.
✓ Branch 2 taken 4440 times.
✗ Branch 3 not taken.
4440 vert = (moveflags & move_use_fake_z) ? &fakez : get_qr(qr_ENEMIESZAXIS) ? &z : &y;
10002
10003
2/2
✓ Branch 0 taken 4408 times.
✓ Branch 1 taken 32 times.
4440 if(++clk2==0) // start it
10004 {
10005 32 x=zc_oldrand()&0xF0;
10006 32 y=-32;
10007 32 clk3=0;
10008 32 clk2=zc_oldrand()&15;
10009 32 }
10010
10011
2/2
✓ Branch 0 taken 842 times.
✓ Branch 1 taken 3598 times.
4440 if(clk2>16) // move it
10012 {
10013
2/2
✓ Branch 0 taken 3467 times.
✓ Branch 1 taken 131 times.
3598 if(clk3<=0) // start bounce
10014 {
10015 131 dir=zc_oldrand()&1;
10016
10017
2/2
✓ Branch 0 taken 121 times.
✓ Branch 1 taken 10 times.
131 if(x<32) dir=1;
10018
10019
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 16 times.
131 if(x>208) dir=0;
10020 131 }
10021
10022
2/2
✓ Branch 0 taken 3487 times.
✓ Branch 1 taken 111 times.
3598 if(clk3<13+16)
10023 {
10024 3487 x += dir ? 1 : -1; //right, left
10025 3487 dummy_int[1]=dir;
10026
10027
2/2
✓ Branch 0 taken 261 times.
✓ Branch 1 taken 3226 times.
3487 if(clk3<2)
10028 {
10029 261 y-=2; //up
10030 261 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
10031 261 }
10032
2/2
✓ Branch 0 taken 382 times.
✓ Branch 1 taken 2844 times.
3226 else if(clk3<5)
10033 {
10034 382 y--; //up
10035 382 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
10036 382 }
10037
2/2
✓ Branch 0 taken 376 times.
✓ Branch 1 taken 2468 times.
2844 else if(clk3<8)
10038 {
10039 376 dummy_int[2]=(dummy_int[1]==1)?right:left;
10040 376 }
10041
2/2
✓ Branch 0 taken 367 times.
✓ Branch 1 taken 2101 times.
2468 else if(clk3<11)
10042 {
10043 367 y++; //down
10044 367 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
10045 367 }
10046 else
10047 {
10048 2101 y+=2; //down
10049 2101 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
10050 }
10051
10052 3487 ++clk3;
10053 3487 }
10054
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 10 times.
111 else if(y<176)
10055 101 clk3=0; // next bounce
10056 else
10057 10 clk2 = -(zc_oldrand()&63); // back to top
10058 3598 }
10059
10060 4440 return enemy::animate(index);
10061 4440 }
10062
10063 4440 void eBoulder::drawshadow(BITMAP *dest, bool translucent)
10064 {
10065
2/2
✓ Branch 0 taken 572 times.
✓ Branch 1 taken 3868 times.
4440 if(clk2>=0)
10066 {
10067 3868 int32_t tempy=yofs;
10068 3868 flip = 0;
10069 3868 int32_t f2=((clk<<2)/frate)<<1;
10070 3868 shadowtile = wpnsbuf[spr_shadow].tile+f2;
10071
6/6
✓ Branch 0 taken 1729 times.
✓ Branch 1 taken 2139 times.
✓ Branch 2 taken 3356 times.
✓ Branch 3 taken 512 times.
✓ Branch 4 taken 1618 times.
✓ Branch 5 taken 1738 times.
3868 yofs+=zc_max(0,zc_min(29-clk3,clk3));
10072
10073 3868 yofs+=8;
10074 3868 xofs-=8;
10075
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
10076 3868 sprite::drawshadow(dest, translucent);
10077 3868 xofs+=16;
10078 3868 ++shadowtile;
10079
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
10080 3868 sprite::drawshadow(dest, translucent);
10081 3868 yofs+=16;
10082 3868 shadowtile+=20;
10083
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
10084 3868 sprite::drawshadow(dest, translucent);
10085 3868 xofs-=16;
10086 3868 --shadowtile;
10087
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
10088 3868 sprite::drawshadow(dest, translucent);
10089 3868 xofs+=8;
10090 3868 yofs=tempy;
10091 3868 }
10092 4440 }
10093
10094 4440 void eBoulder::draw(BITMAP *dest)
10095 {
10096
4/6
✓ Branch 0 taken 572 times.
✓ Branch 1 taken 3868 times.
✓ Branch 2 taken 572 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 572 times.
4440 if(clk2>=0 || fallclk||drownclk)
10097 {
10098 3868 int32_t tempdir=dir;
10099 3868 dir=dummy_int[2];
10100 3868 update_enemy_frame();
10101 3868 dir=tempdir;
10102 3868 xofs-=8;
10103 3868 yofs-=8;
10104 3868 drawblock(dest,15);
10105 3868 xofs+=8;
10106 3868 yofs+=8;
10107 // enemy::draw(dest);
10108 3868 }
10109 4440 }
10110
10111 30 void eBoulder::init_size_flags()
10112 {
10113
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if ((d->SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
10114 30 else hxofs = -10;
10115
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if ((d->SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
10116 30 else hyofs = -10;
10117
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if (((d->SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0) hit_width = d->hxsz;
10118 30 else hit_width = 36;
10119
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if (((d->SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0) hit_height = d->hysz;
10120 30 else hit_height = 36;
10121
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if (((d->SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0) hzsz = d->hzsz;
10122 30 else hzsz = 16; //can't be jumped
10123
10124
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
30 if (((d->SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10125
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
30 if (((d->SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
10126
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if (((d->SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0) hit_width = d->hxsz;
10127
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if ((d->SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)d->xofs;
10128
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if ((d->SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
10129 {
10130 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10131 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
10132 }
10133
10134
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if ((d->SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)d->zofs;
10135 30 }
10136
10137 int32_t eBoulder::takehit(weapon*,weapon*)
10138 {
10139 return 0;
10140 }
10141
10142 4429 eProjectile::eProjectile(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk),
10143
2/2
✓ Branch 0 taken 531 times.
✓ Branch 1 taken 3898 times.
4429 minRange(get_qr(qr_BROKENSTATUES) ? 0 : Clk)
10144 4429 {
10145 /* fixing
10146 hp=1;
10147 */
10148 4429 mainguy=false;
10149
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 4422 times.
4429 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10150 4429 hclk=clk; // the "no fire" range
10151 4429 clk=0;
10152 4429 clk3=96;
10153 4429 timer=0;
10154
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 4415 times.
4429 if(o_tile==0)
10155 {
10156 4415 superman=1;
10157 4415 hxofs=1000;
10158 4415 }
10159
1/4
✓ Branch 0 taken 4429 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4429 if (SIZEflags != 0) init_size_flags();;
10160 4429 }
10161
10162 2504746 bool eProjectile::animate(int32_t index)
10163 {
10164
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2504746 times.
2504746 if(switch_hooked) return enemy::animate(index);
10165
2/4
✓ Branch 0 taken 2504746 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2504746 times.
2504746 if(fallclk||drownclk) return enemy::animate(index);
10166
2/2
✓ Branch 0 taken 2492420 times.
✓ Branch 1 taken 12326 times.
2504746 if(clk==0)
10167 {
10168 12326 removearmos(x,y,ffcactivated);
10169 12326 }
10170
10171 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10172 2504746 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10173
10174
4/4
✓ Branch 0 taken 835608 times.
✓ Branch 1 taken 1669138 times.
✓ Branch 2 taken 431977 times.
✓ Branch 3 taken 403631 times.
2504746 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
10175 {
10176 403631 dir=down;
10177 403631 }
10178
4/4
✓ Branch 0 taken 1348897 times.
✓ Branch 1 taken 752218 times.
✓ Branch 2 taken 431977 times.
✓ Branch 3 taken 916920 times.
2101115 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
10179 {
10180 916920 dir=right;
10181 916920 }
10182
4/4
✓ Branch 0 taken 790877 times.
✓ Branch 1 taken 393318 times.
✓ Branch 2 taken 431977 times.
✓ Branch 3 taken 358900 times.
1184195 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/4)))
10183 {
10184 358900 dir=up;
10185 358900 }
10186 else
10187 {
10188 825295 dir=left;
10189 }
10190
10191
3/4
✓ Branch 0 taken 2504746 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1306267 times.
✓ Branch 3 taken 1198479 times.
2504746 if(!stunclk && ++clk3>80)
10192 {
10193
2/2
✓ Branch 0 taken 1046 times.
✓ Branch 1 taken 1197433 times.
1198479 if(dmisc1==9) // Breath type
10194 {
10195
2/2
✓ Branch 0 taken 483 times.
✓ Branch 1 taken 563 times.
1046 if(timer==0)
10196 {
10197 563 unsigned r=zc_oldrand();
10198
10199
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 557 times.
563 if(!(r&63))
10200 {
10201 6 timer=zc_oldrand()%50+50;
10202 6 }
10203 563 }
10204
10205
2/2
✓ Branch 0 taken 557 times.
✓ Branch 1 taken 489 times.
1046 if(timer>0)
10206 {
10207
2/2
✓ Branch 0 taken 370 times.
✓ Branch 1 taken 119 times.
489 if(timer%4==0)
10208 {
10209 119 FireBreath(false);
10210 119 }
10211
10212
2/2
✓ Branch 0 taken 483 times.
✓ Branch 1 taken 6 times.
489 if(--timer==0)
10213 {
10214 6 clk3=0;
10215 6 }
10216 489 }
10217 1046 }
10218
10219 else // Not breath type
10220 {
10221 1197433 unsigned r=zc_oldrand();
10222
10223
4/4
✓ Branch 0 taken 18808 times.
✓ Branch 1 taken 1178625 times.
✓ Branch 2 taken 1266 times.
✓ Branch 3 taken 17542 times.
1197433 if(!(r&63) && !HeroInRange(minRange))
10224 {
10225 17542 FireWeapon();
10226
10227
4/4
✓ Branch 0 taken 15040 times.
✓ Branch 1 taken 2502 times.
✓ Branch 2 taken 186 times.
✓ Branch 3 taken 66 times.
17794 if(get_qr(qr_BROKENSTATUES)==0 &&
10228
3/4
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 14788 times.
✓ Branch 2 taken 252 times.
✗ Branch 3 not taken.
15040 ((wpn==ewFireball || wpn==ewFireball2) || dmisc1==e1tNORMAL))
10229 {
10230
2/2
✓ Branch 0 taken 13945 times.
✓ Branch 1 taken 909 times.
14854 if(!((r>>7)&15))
10231 {
10232 909 x-=4;
10233 909 FireWeapon();
10234 909 x+=4;
10235 909 }
10236 14854 }
10237
10238 17542 clk3=0;
10239 17542 }
10240 }
10241 1198479 }
10242
10243 2504746 return enemy::animate(index);
10244 2504746 }
10245
10246 2520335 void eProjectile::draw(BITMAP *dest)
10247 {
10248 2520335 update_enemy_frame();
10249 2520335 enemy::draw(dest);
10250 2520335 }
10251
10252 533 eTrigger::eTrigger(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10253 533 {
10254 533 hxofs=1000;
10255 533 }
10256
10257 249811 void eTrigger::draw(BITMAP *dest)
10258 {
10259 249811 update_enemy_frame();
10260 249811 enemy::draw(dest);
10261 249811 }
10262
10263 void eTrigger::death_sfx()
10264 {
10265 //silent death
10266 }
10267
10268 5 eNPC::eNPC(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10269 5 {
10270 5 o_tile+=wpnsbuf[iwNPCs].tile;
10271
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10272 5 SIZEflags = d->SIZEflags;
10273
1/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5 if (SIZEflags != 0) init_size_flags();;
10274 5 }
10275
10276 75 bool eNPC::animate(int32_t index)
10277 {
10278
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
75 if(switch_hooked) return enemy::animate(index);
10279
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 5 times.
75 if(dying)
10280 70 return Dead(index);
10281
10282
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(clk==0)
10283 {
10284 removearmos(x,y,ffcactivated);
10285 }
10286
10287
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
5 switch(dmisc2)
10288 {
10289 case 0:
10290 {
10291 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10292 5 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10293
10294
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
10295 {
10296 dir=down;
10297 }
10298
10299
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
5 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
10300 {
10301 5 dir=right;
10302 5 }
10303 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/8)))
10304 {
10305 dir=up;
10306 }
10307 else
10308 {
10309 dir=left;
10310 }
10311 }
10312 5 break;
10313
10314 case 1:
10315 halting_walk(rate, homing, 0, hrate, 48);
10316
10317 if(clk2==1 && (misc < dmisc1) && !(zc_oldrand()&15))
10318 {
10319 newdir(rate, homing, 0);
10320 clk2=48;
10321 ++misc;
10322 }
10323
10324 if(clk2==0)
10325 misc=0;
10326
10327 break;
10328 }
10329
10330 5 return enemy::animate(index);
10331 75 }
10332
10333 75 void eNPC::draw(BITMAP *dest)
10334 {
10335 75 update_enemy_frame();
10336 75 enemy::draw(dest);
10337 75 }
10338
10339 int32_t eNPC::takehit(weapon*,weapon*)
10340 {
10341 return 0;
10342 }
10343
10344 94 eSpinTile::eSpinTile(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10345 94 {
10346
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
94 if(clk>0) // clk>0 when created by a Spinning Tile combo
10347 {
10348 94 o_tile=clk;
10349 94 cs=id>>12;
10350 94 }
10351
10352 94 id=id&0xFFF;
10353 94 clk=0;
10354
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 step=0;
10355 94 mainguy=false;
10356 94 SIZEflags = d->SIZEflags;
10357
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
94 if (SIZEflags != 0) init_size_flags();;
10358 94 }
10359
10360 81 void eSpinTile::facehero()
10361 {
10362
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 80 times.
81 if(Hero.x-x==0)
10363 {
10364
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (Hero.y + 8 < y)
10365 1 dir = up;
10366 else
10367 dir = down;
10368 1 }
10369 else
10370 {
10371 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10372 80 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10373
10374
4/4
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 58 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 12 times.
80 if((ddir <= -5.0*PI/8.0) && (ddir > -7.0*PI/8.0))
10375 {
10376 12 dir=l_down;
10377 12 }
10378
4/4
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 57 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 1 times.
68 else if ((ddir <= -3.0*PI / 8.0) && (ddir > -5.0*PI / 8.0))
10379 {
10380 1 dir=down;
10381 1 }
10382
4/4
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 45 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 12 times.
67 else if ((ddir <= -1.0*PI / 8.0) && (ddir > -3.0*PI / 8.0))
10383 {
10384 12 dir=r_down;
10385 12 }
10386
4/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 39 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 6 times.
55 else if ((ddir <= 1.0*PI / 8.0) && (ddir > -1.0*PI / 8.0))
10387 {
10388 6 dir=right;
10389 6 }
10390
4/4
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 22 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 17 times.
49 else if ((ddir <= 3.0*PI / 8.0) && (ddir > 1.0*PI / 8.0))
10391 {
10392 17 dir=r_up;
10393 17 }
10394
4/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 8 times.
32 else if ((ddir <= 5.0*PI / 8.0) && (ddir > 3.0*PI / 8.0))
10395 {
10396 8 dir=up;
10397 8 }
10398
4/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 10 times.
24 else if ((ddir <= 7.0*PI / 8.0) && (ddir > 5.0*PI / 8.0))
10399 {
10400 6 dir=l_up;
10401 6 }
10402 else
10403 {
10404 18 dir=left;
10405 }
10406 }
10407 81 }
10408
10409
10410 15539 bool eSpinTile::animate(int32_t index)
10411 {
10412
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15539 times.
15539 if(switch_hooked) return enemy::animate(index);
10413
2/4
✓ Branch 0 taken 15539 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15539 times.
15539 if(fallclk||drownclk) return enemy::animate(index);
10414
2/2
✓ Branch 0 taken 1152 times.
✓ Branch 1 taken 14387 times.
15539 if(dying)
10415 {
10416 1152 return Dead(index);
10417 }
10418
10419
2/2
✓ Branch 0 taken 13146 times.
✓ Branch 1 taken 1241 times.
14387 if(clk==0)
10420 {
10421 1241 removearmos(x,y,ffcactivated);
10422 1241 }
10423
10424 14387 ++misc;
10425
10426
2/2
✓ Branch 0 taken 14306 times.
✓ Branch 1 taken 81 times.
14387 if(misc==96)
10427 {
10428 81 facehero();
10429 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10430 81 double ddir=atan2_MSVC2022_FIX(double((Hero.y)-y),double(Hero.x-x));
10431 81 angular=true;
10432 81 angle=ddir;
10433 81 step=zslongToFix(dstep*100);
10434 81 }
10435
10436
8/8
✓ Branch 0 taken 14374 times.
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 14359 times.
✓ Branch 3 taken 15 times.
✓ Branch 4 taken 14353 times.
✓ Branch 5 taken 6 times.
✓ Branch 6 taken 18 times.
✓ Branch 7 taken 14335 times.
14387 if(y>186 || y<=-16 || x>272 || x<=-16)
10437 52 kickbucket();
10438
10439 14387 sprite::move(step);
10440 14387 return enemy::animate(index);
10441 15539 }
10442
10443 15457 void eSpinTile::draw(BITMAP *dest)
10444 {
10445 15457 update_enemy_frame();
10446 15457 y-=(misc>>4);
10447 15457 yofs+=2;
10448 15457 enemy::draw(dest);
10449 15457 yofs-=2;
10450 15457 y+=(misc>>4);
10451 15457 }
10452
10453 15457 void eSpinTile::drawshadow(BITMAP *dest, bool translucent)
10454 {
10455 15457 flip = 0;
10456 15457 shadowtile = wpnsbuf[spr_shadow].tile+(clk%4);
10457 15457 yofs+=4;
10458
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15457 times.
15457 if(!shadow_overpit(this))
10459 15457 enemy::drawshadow(dest, translucent);
10460 15457 yofs-=4;
10461 15457 }
10462
10463 2765 eZora::eZora(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,0)
10464 2765 {
10465 //these are here to bypass compiler warnings about unused arguments
10466 2765 Clk=Clk;
10467 2765 mainguy=false;
10468
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2765 times.
2765 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10469 /*if((x>-17 && x<0) && iswaterex(tmpscr->data[(((int32_t)y&0xF0)+((int32_t)x>>4))]))
10470 {
10471 clk=1;
10472 }*/
10473 //nets+880;
10474
1/4
✓ Branch 0 taken 2765 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2765 if (SIZEflags != 0) init_size_flags();;
10475 2765 }
10476
10477 623626 void eZora::facehero()
10478 {
10479
2/2
✓ Branch 0 taken 10785 times.
✓ Branch 1 taken 612841 times.
623626 if(Hero.x-x==0)
10480 {
10481 10785 dir=(Hero.y+8<y)?up:down;
10482 10785 }
10483 else
10484 {
10485 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10486 612841 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10487
10488
4/4
✓ Branch 0 taken 124342 times.
✓ Branch 1 taken 488499 times.
✓ Branch 2 taken 46030 times.
✓ Branch 3 taken 78312 times.
612841 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
10489 {
10490 78312 dir=l_down;
10491 78312 }
10492
4/4
✓ Branch 0 taken 90275 times.
✓ Branch 1 taken 444254 times.
✓ Branch 2 taken 46030 times.
✓ Branch 3 taken 44245 times.
534529 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
10493 {
10494 44245 dir=down;
10495 44245 }
10496
4/4
✓ Branch 0 taken 119526 times.
✓ Branch 1 taken 370758 times.
✓ Branch 2 taken 46030 times.
✓ Branch 3 taken 73496 times.
490284 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
10497 {
10498 73496 dir=r_down;
10499 73496 }
10500
4/4
✓ Branch 0 taken 160722 times.
✓ Branch 1 taken 256066 times.
✓ Branch 2 taken 46030 times.
✓ Branch 3 taken 114692 times.
416788 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
10501 {
10502 114692 dir=right;
10503 114692 }
10504
4/4
✓ Branch 0 taken 125815 times.
✓ Branch 1 taken 176281 times.
✓ Branch 2 taken 46030 times.
✓ Branch 3 taken 79785 times.
302096 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
10505 {
10506 79785 dir=r_up;
10507 79785 }
10508
4/4
✓ Branch 0 taken 87885 times.
✓ Branch 1 taken 134426 times.
✓ Branch 2 taken 46030 times.
✓ Branch 3 taken 41855 times.
222311 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
10509 {
10510 41855 dir=up;
10511 41855 }
10512
4/4
✓ Branch 0 taken 120580 times.
✓ Branch 1 taken 59876 times.
✓ Branch 2 taken 74550 times.
✓ Branch 3 taken 46030 times.
180456 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
10513 {
10514 74550 dir=l_up;
10515 74550 }
10516 else
10517 {
10518 105906 dir=left;
10519 }
10520 }
10521 623626 }
10522
10523 852265 bool eZora::animate(int32_t index)
10524 {
10525
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 852265 times.
852265 if(switch_hooked) return enemy::animate(index);
10526
2/2
✓ Branch 0 taken 2754 times.
✓ Branch 1 taken 849511 times.
852265 if(dying)
10527 2754 return Dead(index);
10528
10529
2/2
✓ Branch 0 taken 843799 times.
✓ Branch 1 taken 5712 times.
849511 if(clk==0)
10530 {
10531 5712 removearmos(x,y,ffcactivated);
10532 5712 }
10533
10534
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 849476 times.
849511 if(watch)
10535 {
10536 35 ++clock_zoras[id];
10537 35 return true;
10538 }
10539
10540
2/2
✓ Branch 0 taken 225850 times.
✓ Branch 1 taken 623626 times.
849476 if(get_qr(qr_NEWENEMYTILES))
10541 {
10542 623626 facehero();
10543 623626 }
10544
10545
6/6
✓ Branch 0 taken 5200 times.
✓ Branch 1 taken 4963 times.
✓ Branch 2 taken 4164 times.
✓ Branch 3 taken 825736 times.
✓ Branch 4 taken 6448 times.
✓ Branch 5 taken 2965 times.
849476 switch(clk)
10546 {
10547 case 0: // reposition him
10548 {
10549 6448 int32_t t=0;
10550 6448 int32_t pos2=zc_oldrand()%160 + 16;
10551 6448 bool placed=false;
10552
10553
4/4
✓ Branch 0 taken 6383 times.
✓ Branch 1 taken 38203 times.
✓ Branch 2 taken 26108 times.
✓ Branch 3 taken 5712 times.
44586 while(!placed && t<160)
10554 {
10555 26108 int32_t watertype = iswaterex(tmpscr->data[pos2], currmap, currscr, -1, ((pos2)%16*16), ((pos2)&0xF0), false, true, true, (bool)(editorflags & ENEMY_FLAG7));
10556
5/6
✓ Branch 0 taken 6570 times.
✓ Branch 1 taken 19538 times.
✓ Branch 2 taken 6570 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 400 times.
✓ Branch 5 taken 5647 times.
32155 if(watertype && ((editorflags & ENEMY_FLAG6) ||
10557
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 6538 times.
6570 ((combobuf[watertype].usrflags&cflag1) && (editorflags & ENEMY_FLAG5))
10558
3/4
✓ Branch 0 taken 6538 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6047 times.
✓ Branch 3 taken 6015 times.
6570 || (!(combobuf[watertype].usrflags&cflag1) && !(editorflags & ENEMY_FLAG5))) && (pos2&15)>0 && (pos2&15)<15)
10559 {
10560 5647 x=(pos2&15)<<4;
10561 5647 y=pos2&0xF0;
10562
2/2
✓ Branch 0 taken 340 times.
✓ Branch 1 taken 5307 times.
5647 if (!(editorflags & ENEMY_FLAG8)) hp=guysbuf[id&0xFFF].hp; // refill life each time, unless the flag is checked.
10563 5647 hxofs=1000; // avoid hit detection
10564 5647 stunclk=0;
10565 5647 placed=true;
10566 5647 }
10567
10568 38138 pos2+=19;
10569
10570
2/2
✓ Branch 0 taken 33615 times.
✓ Branch 1 taken 4523 times.
38138 if(pos2>=176)
10571 4523 pos2-=160;
10572
10573 38138 ++t;
10574 }
10575
10576
3/4
✓ Branch 0 taken 5647 times.
✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5647 times.
5712 if(!placed || whistleclk>=88) // can't place him, he's gone
10577 65 return true;
10578
10579 }
10580 5647 break;
10581
10582 case 35:
10583
2/2
✓ Branch 0 taken 3839 times.
✓ Branch 1 taken 1361 times.
5200 if(!get_qr(qr_NEWENEMYTILES))
10584 {
10585 1361 dir=(Hero.y+8<y)?up:down;
10586 1361 }
10587
10588 5200 hxofs=0;
10589 5200 break;
10590
10591 case 35+19:
10592 4963 addEwpn(x,y,z,wpn,2,wdp,dir,getUID(), 0, fakez);
10593 4963 sfx(wpnsfx(wpn),pan(int32_t(x)));
10594 4963 break;
10595
10596 case 35+66:
10597 4164 hxofs=1000;
10598 4164 break;
10599
10600 case 198:
10601 2965 clk=-1;
10602 2965 break;
10603 }
10604
10605 848675 return enemy::animate(index);
10606 851529 }
10607
10608 857650 void eZora::draw(BITMAP *dest)
10609 {
10610
2/2
✓ Branch 0 taken 16963 times.
✓ Branch 1 taken 840687 times.
857650 if(clk<3)
10611 16963 return;
10612
10613 840687 update_enemy_frame();
10614 840687 enemy::draw(dest);
10615 857650 }
10616
10617 232 bool eZora::isSubmerged() const
10618 {
10619 232 return ( clk < 3 );
10620 }
10621
10622
3/6
✓ Branch 0 taken 50116 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 50116 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 50116 times.
✗ Branch 5 not taken.
100232 eStalfos::eStalfos(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10623 50116 {
10624 50116 multishot= timer = fired = dashing = 0;
10625 50116 hashero = false;
10626 50116 dummy_bool[0]=false;
10627
4/8
✓ Branch 0 taken 50116 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 50116 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 50116 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 50116 times.
✗ Branch 7 not taken.
50116 shield= (flags&(guy_shield_left | guy_shield_right | guy_shield_back |guy_shield_front)) != 0;
10628
5/6
✓ Branch 0 taken 962 times.
✓ Branch 1 taken 49154 times.
✓ Branch 2 taken 962 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 497 times.
✓ Branch 5 taken 465 times.
50116 if(dmisc9==e9tARMOS && zc_oldrand()&1)
10629 {
10630
2/4
✓ Branch 0 taken 497 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 497 times.
✗ Branch 3 not taken.
497 step=zslongToFix(dmisc10*100);
10631
10632
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 479 times.
497 if(anim==aARMOS4) o_tile+=20;
10633 497 }
10634
10635
3/4
✓ Branch 0 taken 50116 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 962 times.
✓ Branch 3 taken 49154 times.
50116 if(flags & guy_fade_flicker)
10636 {
10637 962 clk=0;
10638 962 superman = 1;
10639 962 fading=fade_flicker;
10640
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 962 times.
962 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10641 962 dir=down;
10642
10643
4/6
✓ Branch 0 taken 962 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 962 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 409 times.
✓ Branch 5 taken 553 times.
962 if(!canmove(down,(zfix)8,spw_none,false))
10644
3/6
✓ Branch 0 taken 409 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 409 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 409 times.
✗ Branch 5 not taken.
409 clk3=int32_t(13.0/step);
10645 962 }
10646
3/4
✓ Branch 0 taken 49154 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 49021 times.
✓ Branch 3 taken 133 times.
49154 else if(flags & guy_fade_instant)
10647 {
10648 133 clk=0;
10649 133 }
10650
10651
1/2
✓ Branch 0 taken 50116 times.
✗ Branch 1 not taken.
50116 shadowdistance = 0;
10652 50116 clk4 = clk5 = 0;
10653 //nets+2380;
10654
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 50114 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
50116 if (SIZEflags != 0) init_size_flags();;
10655 50116 }
10656
10657 15799797 bool eStalfos::animate(int32_t index)
10658 {
10659
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 15799541 times.
15799797 if(switch_hooked) return enemy::animate(index);
10660
3/4
✓ Branch 0 taken 15799115 times.
✓ Branch 1 taken 426 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 15799115 times.
15799541 if(fallclk||drownclk)
10661 {
10662 426 return enemy::animate(index);
10663 }
10664
2/2
✓ Branch 0 taken 352672 times.
✓ Branch 1 taken 15446443 times.
15799115 if(dying)
10665 {
10666
2/2
✓ Branch 0 taken 352624 times.
✓ Branch 1 taken 48 times.
352672 if(hashero)
10667 {
10668 48 Hero.setEaten(0);
10669 48 hashero=false;
10670 48 }
10671
10672
10/14
✓ Branch 0 taken 35920 times.
✓ Branch 1 taken 316752 times.
✓ Branch 2 taken 3685 times.
✓ Branch 3 taken 32235 times.
✓ Branch 4 taken 187 times.
✓ Branch 5 taken 3498 times.
✓ Branch 6 taken 187 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 187 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 187 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 187 times.
352672 if(dmisc9==e9tROPE && dmisc2==e2tBOMBCHU && !fired && (hp<=0 && !immortal) && hp>-1000 && wpn>wEnemyWeapons)
10673 {
10674 187 hp=-1000;
10675
5/10
✓ Branch 0 taken 187 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 187 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 187 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 187 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 187 times.
✗ Branch 9 not taken.
187 weapon *ew=new weapon(x,y,z, wpn, 0, dmisc4, dir,-1,getUID(),false);
10676 187 Ewpns.add(ew);
10677 187 ew->fakez = fakez;
10678
10679
3/4
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 68 times.
✓ Branch 2 taken 119 times.
✗ Branch 3 not taken.
187 if(wpn==ewSBomb || wpn==ewBomb)
10680 {
10681 187 ew->step=0;
10682 187 ew->id=wpn;
10683 187 ew->misc=50;
10684 187 ew->clk=48;
10685 187 }
10686
10687 187 fired=true;
10688 187 }
10689
6/6
✓ Branch 0 taken 156252 times.
✓ Branch 1 taken 196233 times.
✓ Branch 2 taken 130200 times.
✓ Branch 3 taken 26052 times.
✓ Branch 4 taken 130182 times.
✓ Branch 5 taken 18 times.
352485 else if(wpn && wpn!=ewBrang && dmisc2==e2tFIREOCTO) // Fire Octo
10690 {
10691
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 1 times.
18 if(!dummy_bool[0])
10692 {
10693 1 int32_t wpn2 = wpn+dmisc3;
10694
10695
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(wpn2 <= wEnemyWeapons || wpn2 >= wMax)
10696 {
10697 wpn2=wpn;
10698 }
10699
10700 1 dummy_bool[0]=true;
10701 1 addEwpn(x,y,z,wpn2,0,dmisc4,up, getUID(), 0, fakez);
10702 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10703 1 addEwpn(x,y,z,wpn2,0,dmisc4,down, getUID(), 0, fakez);
10704 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10705 1 addEwpn(x,y,z,wpn2,0,dmisc4,left, getUID(), 0, fakez);
10706 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10707 1 addEwpn(x,y,z,wpn2,0,dmisc4,right, getUID(), 0, fakez);
10708 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10709 1 addEwpn(x,y,z,wpn2,0,dmisc4,l_up, getUID(), 0, fakez);
10710 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10711 1 addEwpn(x,y,z,wpn2,0,dmisc4,r_up, getUID(), 0, fakez);
10712 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10713 1 addEwpn(x,y,z,wpn2,0,dmisc4,l_down, getUID(), 0, fakez);
10714 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10715 1 addEwpn(x,y,z,wpn2,0,dmisc4,r_down, getUID(), 0, fakez);
10716 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10717 1 sfx(wpnsfx(wpn2),pan(int32_t(x)));
10718 1 }
10719 18 }
10720
10721 352672 KillWeapon();
10722 352672 return Dead(index);
10723 }
10724 //vire split
10725 //2.10 checked !fslide(), but nothing uses that now anyway. -Z
10726 //Perhaps the problem occurs when vires die because they have < 0 HP, in this check?
10727
13/14
✓ Branch 0 taken 21124 times.
✓ Branch 1 taken 15425319 times.
✓ Branch 2 taken 21124 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 351 times.
✓ Branch 5 taken 20773 times.
✓ Branch 6 taken 1192696 times.
✓ Branch 7 taken 14253396 times.
✓ Branch 8 taken 1191149 times.
✓ Branch 9 taken 1547 times.
✓ Branch 10 taken 6686 times.
✓ Branch 11 taken 1184463 times.
✓ Branch 12 taken 1326 times.
✓ Branch 13 taken 5360 times.
15446443 else if(((hp<=0 && !immortal) && dmisc2==e2tSPLIT) || (dmisc2==e2tSPLITHIT && hp>0 && hp<guysbuf[id&0xFFF].hp && !slide() && (sclk&255)<=1)) //Split into enemies
10728 {
10729 1677 stop_bgsfx(index);
10730 1677 int32_t kids = guys.Count();
10731 1677 int32_t id2=dmisc3;
10732
2/2
✓ Branch 0 taken 3307 times.
✓ Branch 1 taken 1677 times.
4984 for(int32_t i=0; i < dmisc4; i++)
10733 {
10734 // if (addenemy(x,y,id2+(guysbuf[id2].family==eeKEESE ? 0 : ((i+1)<<12)),-21-(i%4)))
10735
4/6
✓ Branch 0 taken 1272 times.
✓ Branch 1 taken 2035 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2035 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3307 times.
3307 if(addenemy(x,y,id2+(guysbuf[id2].family==eeKEESE ? 0 : ((editorflags & ENEMY_FLAG5) ? 0 : (i<<12))),-21-(i%4)))
10736 3307 ((enemy*)guys.spr(kids+i))->count_enemy = false;
10737 3307 }
10738
10739
2/2
✓ Branch 0 taken 1676 times.
✓ Branch 1 taken 1 times.
1677 if(itemguy) // Hand down the carried item
10740 {
10741 1 guycarryingitem = guys.Count()-1;
10742 1 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
10743 1 itemguy = false;
10744 1 }
10745
10746
2/2
✓ Branch 0 taken 1660 times.
✓ Branch 1 taken 17 times.
1677 if(hashero)
10747 {
10748 17 Hero.setEaten(0);
10749 17 hashero=false;
10750 17 }
10751
10752
4/4
✓ Branch 0 taken 1649 times.
✓ Branch 1 taken 28 times.
✓ Branch 2 taken 1326 times.
✓ Branch 3 taken 323 times.
1677 if(deadsfx > 0 && dmisc2==e2tSPLIT)
10753 323 sfx(deadsfx,pan(int32_t(x)));
10754
10755 1677 return true;
10756 }
10757 /*
10758 else if((dmisc2==e2tSPLITHIT && (hp<=0 && !immortal) &&!slide())) //Possible vires fix; or could cause goodness knows what. -Z
10759 {
10760 stop_bgsfx(index);
10761 int32_t kids = guys.Count();
10762 int32_t id2=dmisc3;
10763
10764 for(int32_t i=0; i < dmisc4; i++)
10765 {
10766 // if (addenemy(x,y,id2+(guysbuf[id2].family==eeKEESE ? 0 : ((i+1)<<12)),-21-(i%4)))
10767 if(addenemy(x,y,id2+(guysbuf[id2].family==eeKEESE ? 0 : (i<<12)),-21-(i%4)))
10768 ((enemy*)guys.spr(kids+i))->count_enemy = false;
10769 }
10770
10771 if(itemguy) // Hand down the carried item
10772 {
10773 guycarryingitem = guys.Count()-1;
10774 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
10775 itemguy = false;
10776 }
10777
10778 if(hashero)
10779 {
10780 Hero.setEaten(0);
10781 hashero=false;
10782 }
10783
10784 return true;
10785 }
10786 */
10787
2/2
✓ Branch 0 taken 68958 times.
✓ Branch 1 taken 15375808 times.
15444766 if(fading)
10788 {
10789
2/2
✓ Branch 0 taken 1192 times.
✓ Branch 1 taken 67766 times.
68958 if(++clk4 > 60)
10790 {
10791 1192 clk4=0;
10792 1192 superman=0;
10793 1192 fading=0;
10794
10795
4/6
✓ Branch 0 taken 931 times.
✓ Branch 1 taken 261 times.
✓ Branch 2 taken 931 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 931 times.
1192 if(flags&guy_armos && z==0 && fakez == 0)
10796 {
10797 //if a custom size (not 16px by 16px)
10798
10799 //if a custom size (not 16px by 16px)
10800
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 931 times.
931 if (ffcactivated)
10801 removearmosffc(ffcactivated-1);
10802 else
10803 {
10804
4/8
✓ Branch 0 taken 931 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 931 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 931 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 931 times.
931 if (txsz > 1 || tysz > 1 || (SIZEflags&OVERRIDE_HIT_WIDTH) || (SIZEflags&OVERRIDE_HIT_HEIGHT) )//remove more than one combo based on enemy size
10805 {
10806 //if removing a block, then adjust y by -1 as the enemy spawns at y+1
10807 for(int32_t dx = 0; dx < tysz; dx ++)
10808 {
10809 for(int32_t dy = 0; dy < tysz; dy++)
10810 {
10811 removearmos((int32_t)x+(dx*16),(int32_t)y+(dy*16)+1);
10812 did_armos = false;
10813 }
10814 removearmos((int32_t)x+(dx*16), (int32_t)y+((tysz-1)*16)+1);
10815 did_armos = false;
10816 }
10817 for(int32_t dy = 0; dy < tysz; dy ++)
10818 {
10819 removearmos((int32_t)x+((txsz-1)*16), (int32_t)y+(dy*16)+1);
10820 did_armos = false;
10821 }
10822 removearmos((int32_t)x+((txsz-1)*16), (int32_t)y+((tysz-1)*16)+1);
10823 }
10824 931 else removearmos(x,y);
10825 }
10826 /*
10827 if (txsz > 1 || tysz > 1 || (SIZEflags&guyflagOVERRIDE_HIT_WIDTH) || (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) )//remove more than one combo based on enemy size
10828 {
10829 //if removing a block, then adjust y by -1 as the enemy spawns at y+1
10830 for(int32_t dx = 0; dx < hxsz; dx += 16)
10831 {
10832 for(int32_t dy = 0; dy < hysz; dy += 16)
10833 {
10834 removearmos((int32_t)x+dx+hxofs,(int32_t)y+dy+hyofs+1,ffcactivated);
10835 did_armos = false;
10836 }
10837 removearmos((int32_t)x+dx+hxofs, (int32_t)y+hyofs+(hysz-1)-1,ffcactivated);
10838 did_armos = false;
10839 }
10840 for(int32_t dy = 0; dy < hysz; dy += 16)
10841 {
10842 removearmos((int32_t)x+hxofs+(hxsz-1), (int32_t)y+dy+hyofs-1,ffcactivated);
10843 did_armos = false;
10844 }
10845 removearmos((int32_t)x+hxofs+(hxsz-1), (int32_t)y+hyofs+(hysz-1)-1,ffcactivated);
10846 }
10847 else removearmos(x,y,ffcactivated);
10848 */
10849
10850 931 }
10851
10852 1192 clk2=0;
10853
10854 1192 newdir();
10855 1192 }
10856 67766 else return enemy::animate(index);
10857 1192 }
10858
6/8
✓ Branch 0 taken 145461 times.
✓ Branch 1 taken 15230347 times.
✓ Branch 2 taken 145461 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 145461 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 136112 times.
✓ Branch 7 taken 9349 times.
15375808 else if(flags&guy_armos && z==0 && fakez == 0 && clk==0)
10859 9349 removearmos(x,y,ffcactivated);
10860
10861
10862
2/2
✓ Branch 0 taken 7207 times.
✓ Branch 1 taken 15369793 times.
15377000 if(hashero)
10863 {
10864 7207 Hero.setX(x);
10865 7207 Hero.setY(y);
10866 7207 ++clk2;
10867
10868
4/4
✓ Branch 0 taken 5694 times.
✓ Branch 1 taken 1513 times.
✓ Branch 2 taken 6308 times.
✓ Branch 3 taken 899 times.
7207 if(clk2==(dmisc8==0 ? 95 : dmisc8))
10869 {
10870
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 877 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
899 switch(dmisc7)
10871 {
10872 case e7tEATITEMS:
10873 {
10874
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 22 times.
5654 for(int32_t i=0; i<MAXITEMS; i++)
10875 {
10876
2/2
✓ Branch 0 taken 5610 times.
✓ Branch 1 taken 22 times.
5632 if(itemsbuf[i].flags&item_edible)
10877 22 game->set_item(i, false);
10878 5632 }
10879
10880 22 break;
10881 }
10882
10883 case e7tEATMAGIC:
10884 game->change_dmagic(-1*game->get_magicdrainrate());
10885 break;
10886
10887 case e7tEATRUPEES:
10888 game->change_drupy(-1);
10889 break;
10890 }
10891
10892 899 clk2=0;
10893 899 }
10894
10895
2/2
✓ Branch 0 taken 546 times.
✓ Branch 1 taken 6661 times.
7207 if((clk&0x18)==8) // stop its animation on the middle frame
10896 6661 --clk;
10897 7207 }
10898
4/4
✓ Branch 0 taken 1048873 times.
✓ Branch 1 taken 14320920 times.
✓ Branch 2 taken 616037 times.
✓ Branch 3 taken 432836 times.
15369793 else if(!(wpn==ewBrang && WeaponOut())) //WeaponOut uses misc
10899 {
10900 // Movement engine
10901
6/6
✓ Branch 0 taken 838865 times.
✓ Branch 1 taken 14098092 times.
✓ Branch 2 taken 3294 times.
✓ Branch 3 taken 108 times.
✓ Branch 4 taken 14094631 times.
✓ Branch 5 taken 59 times.
14936957 if(clk>=0) switch(id>>12)
10902 {
10903 case 0: // Normal movement
10904
10905 /*
10906 if((dmisc9==e9tLEEVER || dmisc9==e9tZ3LEEVER) && !slide()) //Leever
10907 {
10908 // Overloading clk4 (Tribble clock) here...
10909 step=17/100.0;
10910 if(clk4<32) misc=1;
10911 else if(clk4<48) misc=2;
10912 else if(clk4<300) { misc=3; step = dstep/100.0; }
10913 else if(clk4<316) misc=2;
10914 else if(clk4<412) misc=1;
10915 else if(clk4<540) { misc=0; step=0; }
10916 else clk4=0;
10917 if(clk4==48) clk=0;
10918 hxofs=(misc>=2)?0:1000;
10919 if (dmisc9==e9tLEEVER)
10920 variable_walk(rate, homing, 0);
10921 else
10922 variable_walk_8(rate, homing, 4, 0);
10923 break;
10924 }
10925 */
10926
4/4
✓ Branch 0 taken 13715597 times.
✓ Branch 1 taken 379034 times.
✓ Branch 2 taken 417076 times.
✓ Branch 3 taken 13298521 times.
14094631 if(dmisc9==e9tVIRE || dmisc9==e9tPOLSVOICE) //Vire
10927 {
10928 796110 vire_hop();
10929 796110 break;
10930 }
10931
2/2
✓ Branch 0 taken 981551 times.
✓ Branch 1 taken 12316970 times.
13298521 else if(dmisc9==e9tROPE) //Rope charge
10932 {
10933
9/10
✓ Branch 0 taken 964129 times.
✓ Branch 1 taken 17422 times.
✓ Branch 2 taken 138340 times.
✓ Branch 3 taken 825789 times.
✓ Branch 4 taken 126255 times.
✓ Branch 5 taken 12085 times.
✓ Branch 6 taken 125430 times.
✓ Branch 7 taken 825 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 125430 times.
981551 if(!fired && dashing && !stunclk && !watch && !frozenclock)
10934 {
10935
5/6
✓ Branch 0 taken 9076 times.
✓ Branch 1 taken 116354 times.
✓ Branch 2 taken 47 times.
✓ Branch 3 taken 9029 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 47 times.
125430 if(dmisc2==e2tBOMBCHU && HeroInRange(16) && wpn+dmisc3 > wEnemyWeapons) //Bombchu
10936 {
10937
10938
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 33 times.
47 if ( get_qr(qr_BOMBCHUSUPERBOMB) )
10939 {
10940 14 hp=-1000;
10941
10942
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
14 if(wpn+dmisc3 > wEnemyWeapons && wpn+dmisc3 < wMax)
10943 {
10944
5/10
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 14 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 14 times.
✗ Branch 9 not taken.
14 weapon *ew=new weapon(x,y,z, wpn+dmisc3, 0, dmisc4, dir,-1,getUID());
10945 14 Ewpns.add(ew);
10946 14 ew->fakez = fakez;
10947
10948
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
14 if(wpn==ewSBomb || wpn==ewBomb)
10949 {
10950 14 ew->step=0;
10951 14 ew->id=wpn+dmisc3;
10952 14 ew->misc=50;
10953 14 ew->clk=48;
10954 14 }
10955
10956 14 fired=true;
10957 14 }
10958 else
10959 {
10960 weapon *ew=new weapon(x,y,z, wpn, 0, dmisc4, dir,-1,getUID());
10961 Ewpns.add(ew);
10962 ew->fakez = fakez;
10963
10964 if(wpn==ewSBomb || wpn==ewBomb)
10965 {
10966 ew->step=0;
10967 ew->id=wpn;
10968 ew->misc=50;
10969 ew->clk=48;
10970 }
10971
10972 fired=true;
10973 }
10974 14 }
10975
10976 else
10977 {
10978 33 hp=-1000;
10979
10980 int32_t wpn2;
10981
2/4
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 33 times.
33 if(wpn+dmisc3 > wEnemyWeapons && wpn+dmisc3 < wMax)
10982 33 wpn2=wpn;
10983 else
10984 wpn2=wpn;
10985
10986
5/10
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 33 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 33 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 33 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 33 times.
✗ Branch 9 not taken.
33 weapon *ew=new weapon(x,y,z, wpn2, 0, dmisc4, dir,-1,getUID());
10987 33 Ewpns.add(ew);
10988 33 ew->fakez = fakez;
10989
10990
3/4
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
33 if(wpn2==ewSBomb || wpn2==ewBomb)
10991 {
10992 33 ew->step=0;
10993 33 ew->id=wpn2;
10994 33 ew->misc=50;
10995 33 ew->clk=48;
10996 33 }
10997
10998 33 fired=true;
10999 }
11000 47 }
11001 125430 }
11002
11003 981551 charge_attack();
11004 981551 break;
11005 }
11006 /*
11007 * Boomerang-throwers have a halt count of 1
11008 * Zols have a halt count of (zc_oldrand()&7)<<4
11009 * Gels have a halt count of ((zc_oldrand()&7)<<3)+2
11010 * Everything else has 48
11011 */
11012 else
11013 {
11014
2/2
✓ Branch 0 taken 568419 times.
✓ Branch 1 taken 11748551 times.
12316970 if(wpn==ewBrang) // Goriya
11015 {
11016 568419 halting_walk(rate,homing,0,hrate, 1);
11017 568419 }
11018
4/4
✓ Branch 0 taken 11602159 times.
✓ Branch 1 taken 146392 times.
✓ Branch 2 taken 4547551 times.
✓ Branch 3 taken 7054608 times.
11748551 else if(dmisc9==e9tNORMAL && wpn==0)
11019 {
11020
2/2
✓ Branch 0 taken 717973 times.
✓ Branch 1 taken 6336635 times.
7054608 if(dmisc2==e2tSPLITHIT) // Zol
11021 {
11022 717973 halting_walk(rate,homing,0,hrate,(zc_oldrand()&7)<<4);
11023 717973 }
11024
4/4
✓ Branch 0 taken 1753011 times.
✓ Branch 1 taken 4583624 times.
✓ Branch 2 taken 1537120 times.
✓ Branch 3 taken 215891 times.
6336635 else if(frate<=8 && starting_hp==1) // Gel
11025 {
11026 215891 halting_walk(rate,homing,0,hrate,((zc_oldrand()&7)<<3)+2);
11027 215891 }
11028 else // Other
11029 {
11030 6120744 halting_walk(rate,homing,0,hrate, 48);
11031 }
11032 7054608 }
11033 else // Other
11034 {
11035 4693943 halting_walk(rate,homing,0,hrate, 48);
11036 }
11037 }
11038
11039 //if not in midair, and Hero's swinging sword is nearby, jump.
11040 /*if (dmisc9==e9tZ3STALFOS && z==0 && (!(isSideViewGravity()) || !_walkflag(x,y+16,0))
11041 && Hero.getAttackClk()==5 && Hero.getAttack()==wSword && distance(x,y,Hero.getX(),Hero.getY())<32)
11042 {
11043 facehero(false);
11044 sclk=16+((dir^1)<<8);
11045 fall=-FEATHERJUMP;
11046 sfx(WAV_ZN1JUMP,pan(int32_t(x)));
11047 }*/
11048 12316970 break;
11049
11050 // Following cases are for just after creation-by-splitting.
11051 case 1:
11052
2/2
✓ Branch 0 taken 2473 times.
✓ Branch 1 taken 821 times.
3294 if(misc==1)
11053 {
11054 821 dir=up;
11055 821 step=8;
11056 821 }
11057
11058
2/2
✓ Branch 0 taken 790 times.
✓ Branch 1 taken 2504 times.
3294 if(misc<=2)
11059 {
11060 2504 move(step);
11061
11062
2/2
✓ Branch 0 taken 1992 times.
✓ Branch 1 taken 512 times.
2504 if(!canmove(dir,(zfix)0,0,false))
11063 512 dir=down;
11064 2504 }
11065
11066
2/2
✓ Branch 0 taken 2504 times.
✓ Branch 1 taken 790 times.
3294 if(misc==3)
11067 {
11068
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 503 times.
790 if(canmove(right,(zfix)16,0,false))
11069 503 x+=16;
11070 790 }
11071
11072 3294 ++misc;
11073 3294 break;
11074
11075 case 2:
11076
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 15 times.
59 if(misc==1)
11077 {
11078 15 dir=down;
11079 15 step=8;
11080 15 }
11081
11082
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 45 times.
59 if(misc<=2)
11083 {
11084 45 move(step);
11085 /*
11086 if(!canmove(dir,(zfix)0,0,false))
11087 dir=up;
11088 */
11089 45 }
11090
11091
2/2
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 14 times.
59 if(misc==3)
11092 {
11093
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(canmove(left,(zfix)16,0,false))
11094 14 x-=16;
11095 14 }
11096
11097 59 ++misc;
11098 59 break;
11099
11100 default:
11101
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 28 times.
108 if(misc==1)
11102 {
11103 28 dir=(zc_oldrand()%4);
11104 28 step=8;
11105 28 }
11106
11107
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 83 times.
108 if(misc<=2)
11108 {
11109 83 move(step);
11110
11111
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 2 times.
83 if(!canmove(dir,(zfix)0,0,false))
11112 2 dir=dir^1;
11113 83 }
11114
11115
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 25 times.
108 if(misc==3)
11116 {
11117
3/4
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 17 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
25 if(dir >= left && canmove(dir,(zfix)16,0,false))
11118 8 x+=(dir==left ? -16 : 16);
11119 25 }
11120
11121 108 ++misc;
11122 108 break;
11123 14098092 }
11124
11125
4/4
✓ Branch 0 taken 25272 times.
✓ Branch 1 taken 14911685 times.
✓ Branch 2 taken 24443 times.
✓ Branch 3 taken 829 times.
14936957 if(id>>12 && misc>=4) //recently spawned by a split enemy
11126 {
11127 829 id&=0xFFF;
11128 829 step = zslongToFix(dstep*100);
11129
11130
1/2
✓ Branch 0 taken 829 times.
✗ Branch 1 not taken.
829 if(x<32) x=32;
11131
11132
2/2
✓ Branch 0 taken 808 times.
✓ Branch 1 taken 21 times.
829 if(x>208) x=208;
11133
11134
2/2
✓ Branch 0 taken 805 times.
✓ Branch 1 taken 24 times.
829 if(y<32) y=32;
11135
11136
2/2
✓ Branch 0 taken 822 times.
✓ Branch 1 taken 7 times.
829 if(y>128) y=128;
11137
11138 829 misc=3;
11139 829 }
11140 14936957 }
11141 else
11142 {
11143 //sfx(wpnsfx(wpn),pan(int32_t(x)));
11144
1/2
✓ Branch 0 taken 432836 times.
✗ Branch 1 not taken.
432836 if(clk2>2) clk2--;
11145 }
11146
11147 // Fire Zol
11148
8/8
✓ Branch 0 taken 6100121 times.
✓ Branch 1 taken 9276879 times.
✓ Branch 2 taken 139281 times.
✓ Branch 3 taken 5960840 times.
✓ Branch 4 taken 1131 times.
✓ Branch 5 taken 138150 times.
✓ Branch 6 taken 1102 times.
✓ Branch 7 taken 29 times.
15377000 if(wpn && dmisc1==e1tEACHTILE && clk2==1 && !hclk)
11149 {
11150 1102 addEwpn(x,y,z,wpn,0,wdp,dir, getUID(), 0, fakez);
11151 1102 sfx(wpnsfx(wpn),pan(int32_t(x)));
11152
11153 1102 int32_t i=Ewpns.Count()-1;
11154 1102 weapon *ew = (weapon*)(Ewpns.spr(i));
11155
11156
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1102 if(wpn==ewFIRETRAIL && wpnsbuf[ewFIRETRAIL].frames>1)
11157 {
11158 ew->aframe=zc_oldrand()%wpnsbuf[ewFIRETRAIL].frames;
11159 if ( ew->do_animation ) ew->tile+=ew->aframe;
11160 }
11161 1102 }
11162 // Goriya
11163
14/16
✓ Branch 0 taken 1048873 times.
✓ Branch 1 taken 14327025 times.
✓ Branch 2 taken 468534 times.
✓ Branch 3 taken 580339 times.
✓ Branch 4 taken 456235 times.
✓ Branch 5 taken 12299 times.
✓ Branch 6 taken 423258 times.
✓ Branch 7 taken 32977 times.
✓ Branch 8 taken 423258 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 420517 times.
✓ Branch 11 taken 2741 times.
✓ Branch 12 taken 420517 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 414155 times.
✓ Branch 15 taken 6362 times.
15375898 else if(wpn==ewBrang && clk2==1 && sclk==0 && !stunclk && !frozenclock && !watch && wpn && !WeaponOut())
11164 {
11165 6362 misc=index+100;
11166
7/14
✓ Branch 0 taken 6362 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6362 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6362 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6362 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 6362 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 6362 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 6362 times.
✗ Branch 13 not taken.
6362 Ewpns.add(new weapon(x,y-fakez,z,wpn,misc,wdp,dir, -1,getUID(),false));
11167 6362 ((weapon*)Ewpns.spr(Ewpns.Count()-1))->dummy_bool[0]=false;
11168
11169
2/2
✓ Branch 0 taken 6105 times.
✓ Branch 1 taken 257 times.
6362 if(dmisc1==2)
11170 {
11171 257 int32_t ndir=dir;
11172
11173
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 251 times.
257 if(Hero.x-x==0)
11174 {
11175 6 ndir=(Hero.y+8<y)?up:down;
11176 6 }
11177 else //turn to face Hero
11178 {
11179 double _MSVC2022_tmp1, _MSVC2022_tmp2;
11180 251 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
11181
11182
4/4
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 193 times.
✓ Branch 2 taken 45 times.
✓ Branch 3 taken 13 times.
251 if((ddir<=(((-2)*PI)/8))&&(ddir>(((-6)*PI)/8)))
11183 {
11184 13 ndir=down;
11185 13 }
11186
4/4
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 125 times.
✓ Branch 2 taken 45 times.
✓ Branch 3 taken 68 times.
238 else if((ddir<=(((2)*PI)/8))&&(ddir>(((-2)*PI)/8)))
11187 {
11188 68 ndir=right;
11189 68 }
11190
4/4
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 45 times.
✓ Branch 3 taken 48 times.
170 else if((ddir<=(((6)*PI)/8))&&(ddir>(((2)*PI)/8)))
11191 {
11192 48 ndir=up;
11193 48 }
11194 else
11195 {
11196 122 ndir=left;
11197 }
11198 }
11199
11200 257 ((weapon*)Ewpns.spr(Ewpns.Count()-1))->dummy_bool[0]=true;
11201
11202
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 223 times.
257 if(canmove(ndir,false))
11203 {
11204 223 dir=ndir;
11205 223 }
11206 257 }
11207 6362 }
11208
15/16
✓ Branch 0 taken 15310656 times.
✓ Branch 1 taken 58880 times.
✓ Branch 2 taken 221192 times.
✓ Branch 3 taken 15148344 times.
✓ Branch 4 taken 195074 times.
✓ Branch 5 taken 26118 times.
✓ Branch 6 taken 170182 times.
✓ Branch 7 taken 24892 times.
✓ Branch 8 taken 168798 times.
✓ Branch 9 taken 1384 times.
✓ Branch 10 taken 153698 times.
✓ Branch 11 taken 15100 times.
✓ Branch 12 taken 153698 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 944 times.
✓ Branch 15 taken 152754 times.
15369536 else if((clk2==16 || dmisc1==e1tCONSTANT) && dmisc1!=e1tEACHTILE && wpn && wpn!=ewBrang && sclk==0 && !stunclk && !frozenclock && !watch)
11209
3/3
✓ Branch 0 taken 26116 times.
✓ Branch 1 taken 125732 times.
✓ Branch 2 taken 906 times.
152754 switch(dmisc1)
11210 {
11211 case e1tCONSTANT: //Deathnut
11212 {
11213 // Overloading clk5 (Like Like clock) to avoid making another clock just for this attack...
11214
2/2
✓ Branch 0 taken 123149 times.
✓ Branch 1 taken 2583 times.
125732 if(clk5>64)
11215 {
11216 2583 clk5=0;
11217 2583 fired=false;
11218 2583 }
11219
11220 125732 clk5+=(zc_oldrand()&3);
11221
11222
4/4
✓ Branch 0 taken 76714 times.
✓ Branch 1 taken 49018 times.
✓ Branch 2 taken 25645 times.
✓ Branch 3 taken 51069 times.
125732 if((clk5>24)&&(clk5<52))
11223 {
11224
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51069 times.
51069 if ( do_animation )tile+=20; //firing
11225
11226
4/4
✓ Branch 0 taken 27958 times.
✓ Branch 1 taken 23111 times.
✓ Branch 2 taken 25131 times.
✓ Branch 3 taken 2827 times.
51069 if(!fired&&(clk5>=38))
11227 {
11228
5/10
✓ Branch 0 taken 2827 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2827 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2827 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2827 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2827 times.
✗ Branch 9 not taken.
2827 Ewpns.add(new weapon(x,y,z, wpn, 0, wdp, dir, -1,getUID(),false));
11229 2827 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
11230 2827 sfx(wpnsfx(wpn),pan(int32_t(x)));
11231 2827 fired=true;
11232 2827 }
11233 51069 }
11234
11235 125732 break;
11236 }
11237
11238 case e1tFIREOCTO: //Fire Octo
11239 906 timer=zc_oldrand()%50+50;
11240 906 break;
11241
11242 default:
11243 26116 FireWeapon();
11244 26116 break;
11245 152754 }
11246
11247 /* Fire again if:
11248 * - clk2 about to run out
11249 * - not already double-firing (dmisc1 is 1)
11250 * - not carrying Hero
11251 * - one in 0xF chance
11252 */
11253
8/10
✓ Branch 0 taken 524932 times.
✓ Branch 1 taken 14852068 times.
✓ Branch 2 taken 4002 times.
✓ Branch 3 taken 520930 times.
✓ Branch 4 taken 4002 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4002 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3751 times.
✓ Branch 9 taken 251 times.
15377000 if(clk2==1 && (multishot < dmisc6) && dmisc1 != e1tEACHTILE && !hashero && !(zc_oldrand()&15))
11254 {
11255 #if 1
11256 251 newdir(rate, homing, grumble);
11257 #else
11258 dir^=2;
11259 #endif
11260 251 clk2=28;
11261 251 ++multishot;
11262 251 }
11263
11264
2/2
✓ Branch 0 taken 3492313 times.
✓ Branch 1 taken 11884687 times.
15377000 if(clk2==0)
11265 {
11266 11884687 multishot = 0;
11267 11884687 }
11268
11269
2/2
✓ Branch 0 taken 15312690 times.
✓ Branch 1 taken 64310 times.
15377000 if(timer) //Fire Octo
11270 {
11271 64310 clk2=15; //this keeps the octo in place until he's done firing
11272
11273
2/2
✓ Branch 0 taken 48558 times.
✓ Branch 1 taken 15752 times.
64310 if(!(timer%4))
11274 {
11275 15752 FireBreath(false);
11276 15752 }
11277
11278 64310 --timer;
11279 64310 }
11280
11281
2/2
✓ Branch 0 taken 15127607 times.
✓ Branch 1 taken 249393 times.
15377000 if(dmisc2==e2tTRIBBLE)
11282 249393 ++clk4;
11283
11284
7/10
✓ Branch 0 taken 4480 times.
✓ Branch 1 taken 15372520 times.
✓ Branch 2 taken 693 times.
✓ Branch 3 taken 15376307 times.
✓ Branch 4 taken 693 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 693 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 693 times.
15377000 if(clk4==(dmisc5 ? dmisc5 : 256) && (dmisc2==e2tTRIBBLE) && dmisc3 && dmisc4)
11285 {
11286 693 int32_t kids = guys.Count();
11287 693 int32_t id2=dmisc3;
11288
11289
2/2
✓ Branch 0 taken 693 times.
✓ Branch 1 taken 693 times.
1386 for(int32_t i=0; i<dmisc4; i++)
11290 {
11291
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 693 times.
693 if(addenemy(x,y,id2,-24))
11292 {
11293
1/2
✓ Branch 0 taken 693 times.
✗ Branch 1 not taken.
693 if(itemguy) // Hand down the carried item
11294 {
11295 guycarryingitem = guys.Count()-1;
11296 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
11297 itemguy = false;
11298 }
11299
11300 693 ((enemy*)guys.spr(kids+i))->count_enemy = false;
11301 693 }
11302 693 }
11303
11304
1/2
✓ Branch 0 taken 693 times.
✗ Branch 1 not taken.
693 if(hashero)
11305 {
11306 Hero.setEaten(0);
11307 hashero=false;
11308 }
11309
11310 693 stop_bgsfx(index);
11311 693 return true;
11312 }
11313
11314 15376307 return enemy::animate(index);
11315 15799797 }
11316
11317 16195390 void eStalfos::draw(BITMAP *dest)
11318 {
11319 /*if ((dmisc9==e9tLEEVER || dmisc9==e9tZ3LEEVER) && misc<=0) //Submerged
11320 {
11321 clk4--; //Kludge
11322 return;
11323 }*/
11324
11325 /*if ((dmisc9==e9tLEEVER || dmisc9==e9tZ3LEEVER) && misc>1)
11326 {
11327 cs = dcset;
11328 }*/
11329 16195390 update_enemy_frame();
11330
11331
7/8
✓ Branch 0 taken 16194964 times.
✓ Branch 1 taken 426 times.
✓ Branch 2 taken 16194964 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 86951 times.
✓ Branch 5 taken 16108013 times.
✓ Branch 6 taken 75836 times.
✓ Branch 7 taken 11115 times.
16195390 if(!fallclk&&!drownclk&&(dmisc2==e2tBOMBCHU)&&dashing)
11332 {
11333
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11115 times.
11115 if ( do_animation )tile+=20;
11334 11115 }
11335
11336 16195390 enemy::draw(dest);
11337 16195390 }
11338
11339 7494749 void eStalfos::drawshadow(BITMAP *dest, bool translucent)
11340 {
11341 7494749 int32_t tempy=yofs;
11342
11343 /*
11344 if (clk6 && dir>=left && !get_qr(qr_ENEMIESZAXIS)) {
11345 flip = 0;
11346 int32_t f2=get_qr(qr_NEWENEMYTILES)?
11347 (clk/(frate/4)):((clk>=(frate>>1))?1:0);
11348 shadowtile = wpnsbuf[spr_shadow].tile+f2;
11349 yofs+=(((int32_t)y+17)&0xF0)-y;
11350 yofs+=8;
11351 }
11352 */
11353
4/4
✓ Branch 0 taken 7279331 times.
✓ Branch 1 taken 215418 times.
✓ Branch 2 taken 7183130 times.
✓ Branch 3 taken 311619 times.
7494749 if((dmisc9 == e9tPOLSVOICE || dmisc9==e9tVIRE) && !get_qr(qr_ENEMIESZAXIS))
11354 {
11355 311619 flip = 0;
11356 311619 int32_t fdiv = frate/4;
11357
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 311619 times.
311619 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
11358
11359
1/2
✓ Branch 0 taken 311619 times.
✗ Branch 1 not taken.
311619 int32_t f2=get_qr(qr_NEWENEMYTILES)?
11360 311619 efrate:((clk>=(frate>>1))?1:0);
11361 311619 shadowtile = wpnsbuf[spr_shadow].tile;
11362
11363
1/2
✓ Branch 0 taken 311619 times.
✗ Branch 1 not taken.
311619 if(get_qr(qr_NEWENEMYTILES))
11364 {
11365 311619 shadowtile+=f2;
11366 311619 }
11367 else
11368 {
11369 shadowtile+=f2?1:0;
11370 }
11371
11372 311619 yofs+=shadowdistance;
11373 311619 yofs+=8;
11374 311619 }
11375
4/4
✓ Branch 0 taken 7279331 times.
✓ Branch 1 taken 215418 times.
✓ Branch 2 taken 7491714 times.
✓ Branch 3 taken 3035 times.
7494749 if((dmisc9 == e9tPOLSVOICE || dmisc9==e9tVIRE) && !get_qr(qr_POLVIRE_NO_SHADOW))
11376 {
11377 3035 flip = 0;
11378 3035 int32_t fdiv = frate/4;
11379
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3035 times.
3035 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
11380
11381
1/2
✓ Branch 0 taken 3035 times.
✗ Branch 1 not taken.
3035 int32_t f2=get_qr(qr_NEWENEMYTILES)?
11382 3035 efrate:((clk>=(frate>>1))?1:0);
11383 3035 shadowtile = wpnsbuf[spr_shadow].tile;
11384
11385
1/2
✓ Branch 0 taken 3035 times.
✗ Branch 1 not taken.
3035 if(get_qr(qr_NEWENEMYTILES))
11386 {
11387 3035 shadowtile+=f2;
11388 3035 }
11389 else
11390 {
11391 shadowtile+=f2?1:0;
11392 }
11393 3035 }
11394
2/2
✓ Branch 0 taken 5496 times.
✓ Branch 1 taken 7489253 times.
7494749 if(!shadow_overpit(this))
11395 7489253 enemy::drawshadow(dest, translucent);
11396 7494749 yofs=tempy;
11397 7494749 }
11398
11399 157613 int32_t eStalfos::takehit(weapon *w, weapon* realweap)
11400 {
11401 157613 int32_t wpnId = w->id;
11402 157613 int32_t wpnDir = w->dir;
11403
11404
4/4
✓ Branch 0 taken 1418 times.
✓ Branch 1 taken 156195 times.
✓ Branch 2 taken 609 times.
✓ Branch 3 taken 809 times.
157613 if(wpnId==wHammer && shield && (flags & guy_bkshield)
11405
6/8
✓ Branch 0 taken 385 times.
✓ Branch 1 taken 224 times.
✓ Branch 2 taken 385 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 265 times.
✓ Branch 5 taken 120 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 120 times.
609 && ((flags&guy_shield_front && wpnDir==(dir^down)) || (flags&guy_shield_back && wpnDir==(dir^up))
11406
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 120 times.
120 || (flags&guy_shield_left && wpnDir==(dir^left)) || (flags&guy_shield_right && wpnDir==(dir^right))))
11407 {
11408 265 shield = false;
11409 265 flags &= ~(guy_shield_left|guy_shield_right|guy_shield_back|guy_shield_front);
11410
11411
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 243 times.
265 if(get_qr(qr_BRKNSHLDTILES))
11412 243 o_tile=s_tile;
11413 265 }
11414
11415 157613 int32_t ret = enemy::takehit(w,realweap);
11416
11417
4/4
✓ Branch 0 taken 22309 times.
✓ Branch 1 taken 135304 times.
✓ Branch 2 taken 20558 times.
✓ Branch 3 taken 1751 times.
157613 if(sclk && dmisc2==e2tSPLITHIT)
11418 1751 sclk+=128; //Fuck these arbitrary values with no explanation. Fuck vires, too. -Z
11419
11420 157613 return ret;
11421 }
11422
11423 981551 void eStalfos::charge_attack()
11424 {
11425
2/2
✓ Branch 0 taken 6715 times.
✓ Branch 1 taken 974836 times.
981551 if(slide())
11426 6715 return;
11427
11428
10/12
✓ Branch 0 taken 974836 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 972432 times.
✓ Branch 3 taken 2404 times.
✓ Branch 4 taken 942919 times.
✓ Branch 5 taken 29513 times.
✓ Branch 6 taken 921366 times.
✓ Branch 7 taken 21553 times.
✓ Branch 8 taken 915743 times.
✓ Branch 9 taken 5623 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 915743 times.
974836 if(clk<0 || dir<0 || stunclk || watch || ceiling || frozenclock )
11429 59093 return;
11430
11431
2/2
✓ Branch 0 taken 37390 times.
✓ Branch 1 taken 878353 times.
915743 if(clk3<=0)
11432 {
11433 37390 fix_coords(true);
11434
11435
2/2
✓ Branch 0 taken 10009 times.
✓ Branch 1 taken 27381 times.
37390 if(!dashing)
11436 {
11437 27381 int32_t ldir = lined_up(7,false);
11438
11439
4/4
✓ Branch 0 taken 3087 times.
✓ Branch 1 taken 24294 times.
✓ Branch 2 taken 452 times.
✓ Branch 3 taken 2635 times.
27381 if(ldir!=-1 && canmove(ldir,false))
11440 {
11441 2635 dir=ldir;
11442 2635 dashing=true;
11443
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2635 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2635 if(dmisc10<=0 || replay_version_check(0,33))
11444 2635 step=zslongToFix(dstep*100)+1;
11445 else
11446 step=zslongToFix(dmisc10*100);
11447 2635 }
11448 24746 else newdir(4,0,0);
11449 27381 }
11450
11451
2/2
✓ Branch 0 taken 35948 times.
✓ Branch 1 taken 1442 times.
37390 if(!canmove(dir,false))
11452 {
11453 1442 step=zslongToFix(dstep*100);
11454 1442 newdir();
11455 1442 dashing=false;
11456 1442 }
11457
11458 37390 zfix div = step;
11459
11460
1/2
✓ Branch 0 taken 37390 times.
✗ Branch 1 not taken.
37390 if(div == 0)
11461 div = 1;
11462
11463 37390 clk3=(int32_t)(16.0/div);
11464 37390 return;
11465 }
11466
11467 878353 move(step);
11468 878353 --clk3;
11469 981551 }
11470
11471 796110 void eStalfos::vire_hop()
11472 {
11473 //if ( sclk > 0 ) return; //Don't hop during knockback.
11474
11475 // if(dmisc9!=e9tPOLSVOICE)
11476 // {
11477 // //if( slide() /*sclk!=0*/ && dmisc2==e2tSPLIT) //Vires with split on hit, only! -Z
11478 // if( sclk!=0 && dmisc2==e2tSPLIT) //Vires with split on hit, only! -Z
11479 // return; //the enemy should split if it is sliding!
11480 // //else sclk=0; //might need this here, too. -Z
11481 // }
11482
2/2
✓ Branch 0 taken 379034 times.
✓ Branch 1 taken 417076 times.
796110 if(dmisc9!=e9tPOLSVOICE)
11483 {
11484
2/2
✓ Branch 0 taken 372449 times.
✓ Branch 1 taken 6585 times.
379034 if(sclk!=0)
11485 {
11486
2/2
✓ Branch 0 taken 2742 times.
✓ Branch 1 taken 3843 times.
6585 if (dmisc2==e2tSPLITHIT) return;
11487 //return;
11488 3843 }
11489 376292 }
11490 417076 else sclk=0;
11491
11492
8/12
✓ Branch 0 taken 793368 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 793368 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 777885 times.
✓ Branch 5 taken 15483 times.
✓ Branch 6 taken 761476 times.
✓ Branch 7 taken 16409 times.
✓ Branch 8 taken 761476 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 761476 times.
793368 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
11493 31892 return;
11494
11495 761476 int32_t jump_width = (dmisc9==e9tPOLSVOICE) ? 2 : 1;
11496 int32_t jump_height;
11497
11498
1/2
✓ Branch 0 taken 761476 times.
✗ Branch 1 not taken.
761476 if ((dmisc10 <= 0))
11499 761476 jump_height = (dmisc9 == e9tPOLSVOICE) ? 27 : 16;
11500 else jump_height = dmisc10;
11501
11502 761476 y=floor_y;
11503
11504
2/2
✓ Branch 0 taken 735218 times.
✓ Branch 1 taken 26258 times.
761476 if(clk3<=0)
11505 {
11506 26258 fix_coords();
11507
11508 //z=0;
11509 //if we're not in the middle of a jump or if we can't complete the current jump in the current direction
11510 //if(clk2<=0 || !canmove(dir,(zfix)1,spw_floater,false) || (isSideViewGravity() && isOnSideviewPlatform()))
11511
9/10
✓ Branch 0 taken 4922 times.
✓ Branch 1 taken 21336 times.
✓ Branch 2 taken 4320 times.
✓ Branch 3 taken 602 times.
✓ Branch 4 taken 94 times.
✓ Branch 5 taken 4226 times.
✓ Branch 6 taken 42 times.
✓ Branch 7 taken 52 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 42 times.
26258 if(clk2<=0 || !canmove(dir,(zfix)1,spw_floater,false) || (isSideViewGravity() && (isOnSideviewPlatform() || !(moveflags & move_obeys_grav)))) //Vires in old quests
11512 22032 newdir(rate,homing,dmisc9==e9tPOLSVOICE ? spw_floater : spw_none);
11513
11514
2/2
✓ Branch 0 taken 4922 times.
✓ Branch 1 taken 21336 times.
26258 if(clk2<=0)
11515 {
11516 //z=0;
11517
6/6
✓ Branch 0 taken 19015 times.
✓ Branch 1 taken 2321 times.
✓ Branch 2 taken 18569 times.
✓ Branch 3 taken 446 times.
✓ Branch 4 taken 14491 times.
✓ Branch 5 taken 4078 times.
21336 if(!canmove(dir,(zfix)2,spw_none,false) || m_walkflag(x,y,spw_none, dir) || (zc_oldrand()&15)>=hrate)
11518 {
11519
11520
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17258 times.
17258 clk2=(wpn==ewBrang ? 1 : int32_t((16.0*jump_width)/step.getFloat()));
11521 /*if (dmisc9==e9tPOLSVOICE )
11522 {
11523 zprint2("polsvoice jump_width is: %d\n", jump_width);
11524 zprint2("polsvoice raw step is: %d\n", step);
11525 zprint2("polsvoice step.getInt() is: %d\n", step.getInt());
11526 zprint2("setting clk2 on polsvoice to: %d\n", clk2);
11527 }
11528 else
11529 {
11530 zprint2("vire jump_width is: %d\n", jump_width);
11531 zprint2("vire raw step is: %d\n", step);
11532 zprint2("vire step.getInt() is: %d\n", step.getInt());
11533 zprint2("setting clk2 on vire to: %d\n", clk2);
11534 }
11535 */
11536 17258 }
11537 21336 }
11538
11539
4/4
✓ Branch 0 taken 12099 times.
✓ Branch 1 taken 14159 times.
✓ Branch 2 taken 5069 times.
✓ Branch 3 taken 7030 times.
26258 if(dmisc9!=e9tPOLSVOICE && dir>=left) //if we're moving left or right
11540 {
11541 7030 clk2=int32_t((16.0*jump_width)/step.getFloat());
11542 7030 }
11543
11544 26258 clk3=int32_t(16.0/step.getFloat());
11545 26258 }
11546
11547 761476 --clk3;
11548
11549
3/4
✓ Branch 0 taken 361067 times.
✓ Branch 1 taken 400409 times.
✓ Branch 2 taken 361067 times.
✗ Branch 3 not taken.
761476 if(dmisc9==e9tPOLSVOICE || clk2>0)
11550 761476 move(step);
11551
11552 761476 floor_y=y;
11553 761476 clk2--;
11554
11555 //if we're in the middle of a jump
11556
6/6
✓ Branch 0 taken 624929 times.
✓ Branch 1 taken 136547 times.
✓ Branch 2 taken 257704 times.
✓ Branch 3 taken 367225 times.
✓ Branch 4 taken 110653 times.
✓ Branch 5 taken 147051 times.
761476 if(clk2>0 && (dir>=left || dmisc9==e9tPOLSVOICE))
11557 {
11558 477878 int32_t h = fixtoi(fixsin(itofix(clk2*128*step/(16*jump_width)))*jump_height);
11559
11560
4/4
✓ Branch 0 taken 99298 times.
✓ Branch 1 taken 378580 times.
✓ Branch 2 taken 6151 times.
✓ Branch 3 taken 93147 times.
477878 if(get_qr(qr_ENEMIESZAXIS) && !(isSideViewGravity()))
11561 {
11562
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93147 times.
93147 if (moveflags & move_use_fake_z) fakez=h;
11563 93147 else z=h;
11564 93147 }
11565 else
11566 {
11567 //y+=fixtoi(fixsin(itofix((clk2+1)*128*step/(16*jump_width)))*jump_height);
11568 //y-=h;
11569 384731 y=floor_y-h;
11570 384731 shadowdistance=h;
11571 }
11572 477878 }
11573 else
11574 283598 shadowdistance = 0;
11575 796110 }
11576
11577 138 void eStalfos::eathero()
11578 {
11579
5/8
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 68 times.
✓ Branch 2 taken 70 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 70 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 70 times.
138 if(!hashero && Hero.getEaten()==0 && Hero.getAction() != hopping && Hero.getAction() != swimming)
11580 {
11581 70 hashero=true;
11582 70 y=floor_y;
11583 70 z=0;
11584
11585
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70 times.
70 if(Hero.isSwimming())
11586 {
11587 Hero.setX(x);
11588 Hero.setY(y);
11589 }
11590 else
11591 {
11592 70 x=Hero.getX();
11593 70 y=Hero.getY();
11594 }
11595
11596 70 clk2=0;
11597 70 }
11598 138 }
11599
11600 1469390 bool eStalfos::WeaponOut()
11601 {
11602
2/2
✓ Branch 0 taken 2400579 times.
✓ Branch 1 taken 622399 times.
3022978 for(int32_t i=0; i<Ewpns.Count(); i++)
11603 {
11604
3/4
✓ Branch 0 taken 846991 times.
✓ Branch 1 taken 1553588 times.
✓ Branch 2 taken 846991 times.
✗ Branch 3 not taken.
2400579 if(((weapon*)Ewpns.spr(i))->parentid==getUID() && Ewpns.spr(i)->id==ewBrang)
11605 {
11606 846991 return true;
11607 }
11608
11609 /*if (bgsfx > 0 && guys.idCount(id) < 2) // count self
11610 stop_sfx(bgsfx);
11611 */
11612 1553588 }
11613
11614 622399 return false;
11615 1469390 }
11616
11617 352672 void eStalfos::KillWeapon()
11618 {
11619
2/2
✓ Branch 0 taken 293384 times.
✓ Branch 1 taken 352672 times.
646056 for(int32_t i=0; i<Ewpns.Count(); i++)
11620 {
11621
4/4
✓ Branch 0 taken 245286 times.
✓ Branch 1 taken 48098 times.
✓ Branch 2 taken 244476 times.
✓ Branch 3 taken 810 times.
293384 if(((weapon*)Ewpns.spr(i))->type==misc && Ewpns.spr(i)->id==ewBrang)
11622 {
11623 //only kill this Goriya's boomerang -DD
11624
2/2
✓ Branch 0 taken 399 times.
✓ Branch 1 taken 411 times.
810 if(((weapon *)Ewpns.spr(i))->parentid == getUID())
11625 {
11626 411 Ewpns.del(i);
11627 411 }
11628 810 }
11629 293384 }
11630 352672 }
11631
11632 void eStalfos::break_shield()
11633 {
11634 if(!shield)
11635 return;
11636
11637 flags&=~(guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right);
11638 shield=false;
11639
11640 if(get_qr(qr_BRKNSHLDTILES))
11641 o_tile=s_tile;
11642 }
11643
11644 void eStalfos::repair_shield()
11645 {
11646 if (shield)
11647 return;
11648
11649 shield = true;
11650
11651 if (get_qr(qr_BRKNSHLDTILES))
11652 {
11653 if get_qr(qr_NEWENEMYTILES) o_tile = d->e_tile;
11654 else o_tile = d->tile;
11655 }
11656 }
11657
11658 13582 eKeese::eKeese(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
11659 13582 {
11660
1/2
✓ Branch 0 taken 13582 times.
✗ Branch 1 not taken.
13582 dir=(zc_oldrand()&7)+8;
11661
1/2
✓ Branch 0 taken 13582 times.
✗ Branch 1 not taken.
13582 step=0;
11662 13582 movestatus=1;
11663
3/4
✓ Branch 0 taken 10458 times.
✓ Branch 1 taken 3124 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10458 times.
13582 if (dmisc1 != 1 && dmisc19 > 0)
11664 {
11665 step = dmisc19/100.0;
11666 movestatus = 1;
11667 }
11668
1/2
✓ Branch 0 taken 13582 times.
✗ Branch 1 not taken.
13582 if (dmisc1 == 2) movestatus=2;
11669 13582 c=0;
11670 13582 clk4=0;
11671 //nets;
11672
1/2
✓ Branch 0 taken 13582 times.
✗ Branch 1 not taken.
13582 init_size_flags();
11673 13582 dummy_int[1]=0;
11674 13582 }
11675
11676 3505411 bool eKeese::animate(int32_t index)
11677 {
11678
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3505411 times.
3505411 if(switch_hooked) return enemy::animate(index);
11679
2/4
✓ Branch 0 taken 3505411 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3505411 times.
3505411 if(fallclk||drownclk) return enemy::animate(index);
11680
2/2
✓ Branch 0 taken 124201 times.
✓ Branch 1 taken 3381210 times.
3505411 if(dying)
11681 124201 return Dead(index);
11682
11683
2/2
✓ Branch 0 taken 3355205 times.
✓ Branch 1 taken 26005 times.
3381210 if(clk==0)
11684 {
11685 26005 removearmos(x,y,ffcactivated);
11686 26005 }
11687
11688
2/2
✓ Branch 0 taken 1025042 times.
✓ Branch 1 taken 2356168 times.
3381210 if(dmisc1 == 1) //Walk style. 0 is keese, 1 is bat.
11689 {
11690 1025042 floater_walk(rate,hrate,dstep/100,(zfix)0,10,dmisc16,dmisc17);
11691 1025042 }
11692 else
11693 {
11694
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2356168 times.
2356168 if (dmisc18) floater_walk(rate,hrate,dstep/100,dmisc18/100.0,-1,dmisc16,dmisc17);
11695 2356168 else floater_walk(rate,hrate,dstep/100,dstep/1000,10,dmisc16,dmisc17);
11696 }
11697
11698
2/2
✓ Branch 0 taken 120338 times.
✓ Branch 1 taken 3260872 times.
3381210 if(dmisc2 == e2tKEESETRIB)
11699 {
11700
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 120338 times.
✓ Branch 2 taken 120147 times.
✓ Branch 3 taken 191 times.
120338 if(++clk4==(dmisc20>0?dmisc20:256))
11701 {
11702
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 105 times.
191 if(!m_walkflag(x,y,0, dir))
11703 {
11704 105 int32_t kids = guys.Count();
11705 105 bool success = false;
11706 105 int32_t id2=dmisc3;
11707 105 success = 0 != addenemy((zfix)x,(zfix)y,id2,-24);
11708
11709
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if(success)
11710 {
11711
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(itemguy) // Hand down the carried item
11712 {
11713 guycarryingitem = guys.Count()-1;
11714 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
11715 itemguy = false;
11716 }
11717
11718 105 ((enemy*)guys.spr(kids))->count_enemy = count_enemy;
11719 105 }
11720
11721 105 stop_bgsfx(index);
11722 105 return true;
11723 }
11724 else
11725 {
11726 86 clk4=0;
11727 }
11728 86 }
11729 120233 }
11730 // Keese Tribbles stay on the ground, so there's no problem when they transform.
11731
3/4
✓ Branch 0 taken 845879 times.
✓ Branch 1 taken 2414993 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 845879 times.
3260872 else if(get_qr(qr_ENEMIESZAXIS) && !(isSideViewGravity()))
11732 {
11733
2/2
✓ Branch 0 taken 687068 times.
✓ Branch 1 taken 158811 times.
845879 if (get_qr(qr_OLD_KEESE_Z_AXIS))
11734 {
11735
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 687068 times.
687068 if (moveflags & move_use_fake_z)
11736 {
11737 fakez=int32_t(step/zslongToFix(dstep*100));
11738 // Some variance in keese flight heights when away from Hero
11739 fakez+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-128)/10));
11740
11741 }
11742 else
11743 {
11744 687068 z=int32_t(step/zslongToFix(dstep*100));
11745 // Some variance in keese flight heights when away from Hero
11746
2/2
✓ Branch 0 taken 503635 times.
✓ Branch 1 taken 183433 times.
687068 z+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-128)/10));
11747 }
11748 687068 }
11749 else
11750 {
11751
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 158811 times.
158811 if (moveflags & move_use_fake_z)
11752 {
11753 fakez=int32_t(step/zslongToFix(dstep*100));
11754 // Some variance in keese flight heights when away from Hero
11755 fakez+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-40)/4));
11756
11757 }
11758 else
11759 {
11760 158811 z=int32_t(step/zslongToFix(dstep*100));
11761 // Some variance in keese flight heights when away from Hero
11762
2/2
✓ Branch 0 taken 16841 times.
✓ Branch 1 taken 141970 times.
158811 z+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-40)/4));
11763 }
11764 }
11765 845879 }
11766
11767 3381105 return enemy::animate(index);
11768 3505411 }
11769
11770 2056065 void eKeese::drawshadow(BITMAP *dest, bool translucent)
11771 {
11772 2056065 int32_t tempy=yofs;
11773 2056065 flip = 0;
11774 2056065 shadowtile = wpnsbuf[spr_shadow].tile+posframe;
11775
11776
2/2
✓ Branch 0 taken 653085 times.
✓ Branch 1 taken 1402980 times.
2056065 yofs+=zc_min(int32_t(step/zslongToFix(dstep*10)), 8);
11777
2/2
✓ Branch 0 taken 690563 times.
✓ Branch 1 taken 1365502 times.
2056065 if(!get_qr(qr_ENEMIESZAXIS))
11778 {
11779 1365502 yofs+=int32_t(step/zslongToFix(dstep*10));
11780 1365502 }
11781
11782
6/6
✓ Branch 0 taken 2035375 times.
✓ Branch 1 taken 20690 times.
✓ Branch 2 taken 676820 times.
✓ Branch 3 taken 1358555 times.
✓ Branch 4 taken 661452 times.
✓ Branch 5 taken 15368 times.
2056065 if(!shadow_overpit(this) && (!get_qr(qr_ENEMIESZAXIS) || step > 0))
11783 2020007 enemy::drawshadow(dest, translucent);
11784 2056065 yofs=tempy;
11785 2056065 }
11786
11787 7885431 void eKeese::draw(BITMAP *dest)
11788 {
11789 7885431 update_enemy_frame();
11790 7885431 enemy::draw(dest);
11791 7885431 }
11792
11793 13582 void eKeese::init_size_flags()
11794 {
11795 13582 SIZEflags = d->SIZEflags;
11796
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13582 times.
13582 if (!(SIZEflags & OVERRIDE_HIT_X_OFFSET)) hxofs = 2;
11797
1/2
✓ Branch 0 taken 13582 times.
✗ Branch 1 not taken.
13582 if ((SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
11798
11799
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13582 times.
13582 if (!(SIZEflags & OVERRIDE_HIT_WIDTH)) hit_width = 12;
11800
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13582 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13582 if (((SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0) hit_width = d->hxsz;
11801
11802
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13582 times.
13582 if (!(SIZEflags & OVERRIDE_HIT_Y_OFFSET)) hyofs = 4;
11803
1/2
✓ Branch 0 taken 13582 times.
✗ Branch 1 not taken.
13582 if ((SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
11804
11805
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13582 times.
13582 if (!(SIZEflags & OVERRIDE_HIT_HEIGHT)) hit_height = 8;
11806
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13582 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13582 if (((SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0) hit_height = d->hysz;
11807
11808
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 13582 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
13582 if (((SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
11809 // al_trace("Enemy txsz:%i\n", txsz);
11810
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 13582 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
13582 if (((SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
11811
11812
11813
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13582 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13582 if (((SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0) hzsz = d->hzsz;
11814
11815
1/2
✓ Branch 0 taken 13582 times.
✗ Branch 1 not taken.
13582 if ((SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)d->xofs;
11816
1/2
✓ Branch 0 taken 13582 times.
✗ Branch 1 not taken.
13582 if ((SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
11817 {
11818 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
11819 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
11820 }
11821
11822
1/2
✓ Branch 0 taken 13582 times.
✗ Branch 1 not taken.
13582 if ((SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)d->zofs;
11823 13582 }
11824
11825 20081 void eWizzrobe::submerge(bool set)
11826 {
11827
2/2
✓ Branch 0 taken 19934 times.
✓ Branch 1 taken 147 times.
20081 if(get_qr(qr_OLD_WIZZROBE_SUBMERGING))
11828 {
11829 19934 hxofs = set?1000:0;
11830 19934 return;
11831 }
11832
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 147 times.
147 if(submerged == set) return;
11833 147 submerged = set;
11834
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 71 times.
147 if(set)
11835 76 hxofs+=1000;
11836 71 else hxofs -= 1000;
11837 20081 }
11838 5326 eWizzrobe::eWizzrobe(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
11839 5326 {
11840 5326 hxofs = 0;
11841 5326 submerged = false;
11842
2/2
✓ Branch 0 taken 2358 times.
✓ Branch 1 taken 2968 times.
5326 switch(dmisc1)
11843 {
11844 case 0:
11845 2968 submerge(true);
11846 2968 fading=fade_invisible;
11847 // Set clk to just before the 'reappear' threshold
11848
9/10
✓ Branch 0 taken 2967 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 2967 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 1184 times.
✓ Branch 5 taken 1784 times.
✓ Branch 6 taken 1184 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1783 times.
✓ Branch 9 taken 1 times.
2968 clk=zc_min(clk+(146+zc_max(0,dmisc5))+14,(146+zc_max(0,dmisc5))-1);
11849 2968 break;
11850
11851 default:
11852 2358 dir=(loadside==right)?right:left;
11853 2358 misc=-3;
11854 2358 break;
11855 }
11856
11857 //netst+2880;
11858 5326 charging=false;
11859 5326 firing=false;
11860 5326 fclk=0;
11861
2/2
✓ Branch 0 taken 2358 times.
✓ Branch 1 taken 2968 times.
5326 if(!dmisc1) frate=1200+146; //1200 = 20 seconds
11862
1/4
✓ Branch 0 taken 5326 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5326 if (SIZEflags != 0) init_size_flags();;
11863 5326 }
11864
11865 2075375 bool eWizzrobe::animate(int32_t index)
11866 {
11867
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2075375 times.
2075375 if(switch_hooked) return enemy::animate(index);
11868
2/4
✓ Branch 0 taken 2075375 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2075375 times.
2075375 if(fallclk||drownclk) return enemy::animate(index);
11869
2/2
✓ Branch 0 taken 37967 times.
✓ Branch 1 taken 2037408 times.
2075375 if(dying)
11870 {
11871 37967 return Dead(index);
11872 }
11873
11874
2/2
✓ Branch 0 taken 1970803 times.
✓ Branch 1 taken 66605 times.
2037408 if(clk==0)
11875 {
11876 66605 removearmos(x,y,ffcactivated);
11877 66605 }
11878
11879
2/2
✓ Branch 0 taken 1019220 times.
✓ Branch 1 taken 1018188 times.
2037408 if(dmisc1) // Floating
11880 {
11881 1019220 wizzrobe_attack();
11882 1019220 }
11883 else // Teleporting
11884 {
11885
5/6
✓ Branch 0 taken 1011104 times.
✓ Branch 1 taken 7084 times.
✓ Branch 2 taken 11087 times.
✓ Branch 3 taken 1000017 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 11087 times.
1018188 if(watch || (!get_qr(qr_WIZZROBES_DONT_OBEY_STUN) && stunclk))
11886 {
11887 7084 fading=0;
11888 7084 submerge(false);
11889 7084 solid_update(false);
11890 7084 }
11891
8/8
✓ Branch 0 taken 977386 times.
✓ Branch 1 taken 6199 times.
✓ Branch 2 taken 5284 times.
✓ Branch 3 taken 5122 times.
✓ Branch 4 taken 4977 times.
✓ Branch 5 taken 4222 times.
✓ Branch 6 taken 4084 times.
✓ Branch 7 taken 3830 times.
1011104 else switch(clk)
11892 {
11893 case 0:
11894
2/2
✓ Branch 0 taken 1117 times.
✓ Branch 1 taken 5082 times.
6199 if(!dmisc2)
11895 {
11896 // Wizzrobe Misc4 controls whether wizzrobes can teleport on top of solid combos,
11897 // but should not appear on dungeon walls.
11898
2/2
✓ Branch 0 taken 413 times.
✓ Branch 1 taken 4669 times.
5082 if ( FFCore.getQuestHeaderInfo(vZelda) <= 0x190 ) place_on_axis(true, false); //1.84, and probably 1.90 wizzrobes should NEVER appear in dungeon walls.-Z (1.84 confirmed, 15th January, 2019 by Chris Miller).
11899
2/2
✓ Branch 0 taken 224 times.
✓ Branch 1 taken 4445 times.
4669 else if (editorflags&ENEMY_FLAG5)
11900 {
11901 //2.10 Windrobe
11902 //randomise location and face Hero
11903 224 int32_t t=0;
11904 224 bool placed=false;
11905
11906
4/4
✓ Branch 0 taken 224 times.
✓ Branch 1 taken 367 times.
✓ Branch 2 taken 367 times.
✓ Branch 3 taken 224 times.
591 while(!placed && t<160)
11907 {
11908
2/2
✓ Branch 0 taken 280 times.
✓ Branch 1 taken 87 times.
367 if(isdungeon())
11909 {
11910 280 x=((zc_oldrand()%12)+2)*16;
11911 280 y=((zc_oldrand()%7)+2)*16;
11912 280 }
11913 else
11914 {
11915 87 x=((zc_oldrand()%14)+1)*16;
11916 87 y=((zc_oldrand()%9)+1)*16;
11917 }
11918
11919
6/6
✓ Branch 0 taken 123 times.
✓ Branch 1 taken 244 times.
✓ Branch 2 taken 187 times.
✓ Branch 3 taken 57 times.
✓ Branch 4 taken 143 times.
✓ Branch 5 taken 224 times.
611 if(!m_walkflag(x,y,spw_door, dir)&&((abs(x-Hero.getX())>=32)||(abs(y-Hero.getY())>=32)))
11920 {
11921 224 placed=true;
11922 224 }
11923
11924 367 ++t;
11925 }
11926
11927
2/2
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 163 times.
224 if(abs(x-Hero.getX())<abs(y-Hero.getY()))
11928 {
11929
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 14 times.
61 if(y<Hero.getY())
11930 {
11931 47 dir=down;
11932 47 }
11933 else
11934 {
11935 14 dir=up;
11936 }
11937 61 }
11938 else
11939 {
11940
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 72 times.
163 if(x<Hero.getX())
11941 {
11942 72 dir=right;
11943 72 }
11944 else
11945 {
11946 91 dir=left;
11947 }
11948 }
11949
11950
1/2
✓ Branch 0 taken 224 times.
✗ Branch 1 not taken.
224 if(!placed) // can't place him, he's gone
11951 return true;
11952
11953
11954 //wizzrobe_attack(); //Complaint about 2.10 Windrobes not behaving as they did in 2.10. Let's try it this way. -Z
11955 //wizzrobe_attack_for_real(); //doing this makes them fire twice. The rest is correct.
11956 224 }
11957 4445 else place_on_axis(true, dmisc4!=0);
11958 5082 }
11959 else
11960 {
11961 1117 int32_t t=0;
11962 1117 bool placed=false;
11963
11964
4/4
✓ Branch 0 taken 1117 times.
✓ Branch 1 taken 2443 times.
✓ Branch 2 taken 2443 times.
✓ Branch 3 taken 1117 times.
3560 while(!placed && t<160)
11965 {
11966
2/2
✓ Branch 0 taken 1340 times.
✓ Branch 1 taken 1103 times.
2443 if(isdungeon())
11967 {
11968 1340 x=((zc_oldrand()%12)+2)*16;
11969 1340 y=((zc_oldrand()%7)+2)*16;
11970 1340 }
11971 else
11972 {
11973 1103 x=((zc_oldrand()%14)+1)*16;
11974 1103 y=((zc_oldrand()%9)+1)*16;
11975 }
11976
11977
6/6
✓ Branch 0 taken 1130 times.
✓ Branch 1 taken 1313 times.
✓ Branch 2 taken 898 times.
✓ Branch 3 taken 415 times.
✓ Branch 4 taken 1326 times.
✓ Branch 5 taken 1117 times.
3756 if(!m_walkflag(x,y,spw_door, dir)&&((abs(x-Hero.getX())>=32)||(abs(y-Hero.getY())>=32)))
11978 {
11979 1117 placed=true;
11980 1117 }
11981
11982 2443 ++t;
11983 }
11984
11985
2/2
✓ Branch 0 taken 386 times.
✓ Branch 1 taken 731 times.
1117 if(abs(x-Hero.getX())<abs(y-Hero.getY()))
11986 {
11987
2/2
✓ Branch 0 taken 238 times.
✓ Branch 1 taken 148 times.
386 if(y<Hero.getY())
11988 {
11989 238 dir=down;
11990 238 }
11991 else
11992 {
11993 148 dir=up;
11994 }
11995 386 }
11996 else
11997 {
11998
2/2
✓ Branch 0 taken 340 times.
✓ Branch 1 taken 391 times.
731 if(x<Hero.getX())
11999 {
12000 340 dir=right;
12001 340 }
12002 else
12003 {
12004 391 dir=left;
12005 }
12006 }
12007
12008
1/2
✓ Branch 0 taken 1117 times.
✗ Branch 1 not taken.
1117 if(!placed) // can't place him, he's gone
12009 return true;
12010 }
12011
12012 6199 fading=fade_flicker;
12013 6199 submerge(false);
12014 6199 solid_update(false);
12015 6199 break;
12016
12017 case 64:
12018 5284 fading=0;
12019 5284 charging=true;
12020 5284 break;
12021
12022 case 73:
12023 5122 charging=false;
12024 5122 firing=40;
12025 5122 break;
12026
12027 case 83:
12028 4977 wizzrobe_attack_for_real();
12029 4977 break;
12030
12031 case 119:
12032 4222 firing=false;
12033 4222 charging=true;
12034 4222 break;
12035
12036 case 128:
12037 4084 fading=fade_flicker;
12038 4084 charging=false;
12039 4084 break;
12040
12041 case 146:
12042 3830 fading=fade_invisible;
12043 3830 submerge(true);
12044 3830 solid_update(false);
12045
12046 [[fallthrough]];
12047 default:
12048
4/4
✓ Branch 0 taken 981056 times.
✓ Branch 1 taken 160 times.
✓ Branch 2 taken 975008 times.
✓ Branch 3 taken 6208 times.
981216 if(clk>=(146+zc_max(0,dmisc5)))
12049 6208 clk=-1;
12050
12051 981216 break;
12052 }
12053 }
12054
12055 2037408 return enemy::animate(index);
12056 2075375 }
12057
12058 7900 void eWizzrobe::wizzrobe_attack_for_real()
12059 {
12060
1/2
✓ Branch 0 taken 7900 times.
✗ Branch 1 not taken.
7900 if(wpn==0) // Edited enemies
12061 return;
12062
12063
2/2
✓ Branch 0 taken 1983 times.
✓ Branch 1 taken 5917 times.
7900 if(dmisc2 == 0) //normal weapon
12064 {
12065 5917 addEwpn(x,y,z,wpn,0,wdp,dir,getUID(), 0, fakez);
12066 5917 sfx(firesfx, pan(int32_t(x)));
12067 5917 }
12068
2/2
✓ Branch 0 taken 995 times.
✓ Branch 1 taken 988 times.
1983 else if(dmisc2 == 1) // ring of fire
12069 {
12070 995 addEwpn(x,y,z,wpn,0,wdp,up,getUID(), 0, fakez);
12071 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
12072 995 addEwpn(x,y,z,wpn,0,wdp,down,getUID(), 0, fakez);
12073 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
12074 995 addEwpn(x,y,z,wpn,0,wdp,left,getUID(), 0, fakez);
12075 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
12076 995 addEwpn(x,y,z,wpn,0,wdp,right,getUID(), 0, fakez);
12077 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
12078 995 addEwpn(x,y,z,wpn,0,wdp,l_up,getUID(), 0, fakez);
12079 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
12080 995 addEwpn(x,y,z,wpn,0,wdp,r_up,getUID(), 0, fakez);
12081 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
12082 995 addEwpn(x,y,z,wpn,0,wdp,l_down,getUID(), 0, fakez);
12083 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
12084 995 addEwpn(x,y,z,wpn,0,wdp,r_down,getUID(), 0, fakez);
12085 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
12086 //this block of code was buggy and flat out doesn't match the default wpnsfx for these weapons.
12087 //i've compromised by making all old quest use this code chunk by default.
12088
1/2
✓ Branch 0 taken 995 times.
✗ Branch 1 not taken.
995 if (FFCore.quest_format[vGuys] < 51)
12089 {
12090 995 sfx(WAV_FIRE, pan(int32_t(x)));
12091
2/2
✓ Branch 0 taken 488 times.
✓ Branch 1 taken 507 times.
995 if (get_qr(qr_8WAY_SHOT_SFX_DEP)) sfx(WAV_FIRE,pan(int32_t(x)));
12092 else
12093 {
12094
3/17
✗ Branch 0 not taken.
✓ Branch 1 taken 19 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 68 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 420 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
507 switch (wpn)
12095 {
12096 19 case ewFireball: sfx(40, pan(int32_t(x))); break;
12097 case ewBrang: sfx(4, pan(int32_t(x))); break; //Ghost.zh has 0?
12098 case ewSword: sfx(20, pan(int32_t(x))); break; //Ghost.zh has 0?
12099 case ewRock: sfx(51, pan(int32_t(x))); break;
12100 68 case ewMagic: sfx(32, pan(int32_t(x))); break;
12101 case ewBomb: sfx(3, pan(int32_t(x))); break; //Ghost.zh has 0?
12102 case ewSBomb: sfx(3, pan(int32_t(x))); break; //Ghost.zh has 0?
12103 case ewLitBomb: sfx(21, pan(int32_t(x))); break; //Ghost.zh has 0?
12104 case ewLitSBomb: sfx(21, pan(int32_t(x))); break; //Ghost.zh has 0?
12105 case ewFireTrail: sfx(13, pan(int32_t(x))); break;
12106 420 case ewFlame: sfx(13, pan(int32_t(x))); break;
12107 case ewWind: sfx(32, pan(int32_t(x))); break;
12108 case ewFlame2: sfx(13, pan(int32_t(x))); break;
12109 case ewFlame2Trail: sfx(13, pan(int32_t(x))); break;
12110 case ewIce: sfx(44, pan(int32_t(x))); break;
12111 case ewFireball2: sfx(40, pan(int32_t(x))); break; //fireball (rising)
12112 default: sfx(WAV_FIRE, pan(int32_t(x))); break;
12113 }
12114 }
12115 995 }
12116 else
12117 {
12118 sfx(firesfx, pan(int32_t(x)));
12119 }
12120 995 }
12121
2/2
✓ Branch 0 taken 971 times.
✓ Branch 1 taken 17 times.
988 else if(dmisc2==2) // summons specific enemy
12122 {
12123 971 int32_t bc=0;
12124
12125
2/2
✓ Branch 0 taken 10497 times.
✓ Branch 1 taken 971 times.
11468 for(int32_t gc=0; gc<guys.Count(); gc++)
12126 {
12127
2/2
✓ Branch 0 taken 5302 times.
✓ Branch 1 taken 5195 times.
10497 if((((enemy*)guys.spr(gc))->id) == dmisc3)
12128 {
12129 5195 ++bc;
12130 5195 }
12131 10497 }
12132
12133
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 963 times.
971 if(bc<=40)
12134 {
12135 963 int32_t kids = guys.Count();
12136 963 int32_t bats=(zc_oldrand()%3)+1;
12137
12138
2/2
✓ Branch 0 taken 1965 times.
✓ Branch 1 taken 963 times.
2928 for(int32_t i=0; i<bats; i++)
12139 {
12140 // Summon bats (or anything)
12141
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1965 times.
1965 if(addchild(x,y,dmisc3,-10, this->script_UID))
12142 1965 ((enemy*)guys.spr(kids+i))->count_enemy = false;
12143 1965 }
12144 963 sfx(firesfx, pan(int32_t(x)));
12145 963 }
12146 971 }
12147
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 else if(dmisc2==3) //summon from layer
12148 {
12149
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(count_layer_enemies()==0)
12150 {
12151 return;
12152 }
12153
12154 17 int32_t kids = guys.Count();
12155
12156
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if(kids<200)
12157 {
12158 17 int32_t newguys=(zc_oldrand()%3)+1;
12159 17 bool summoned=false;
12160
12161
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 17 times.
49 for(int32_t i=0; i<newguys; i++)
12162 {
12163 32 int32_t id2=vbound(random_layer_enemy(),eSTART,eMAXGUYS-1);
12164 32 int32_t x2=0;
12165 32 int32_t y2=0;
12166
12167
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 for(int32_t k=0; k<20; ++k)
12168 {
12169 36 x2=16*((zc_oldrand()%12)+2);
12170 36 y2=16*((zc_oldrand()%7)+2);
12171
12172
5/6
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
✓ Branch 2 taken 21 times.
✓ Branch 3 taken 15 times.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 32 times.
72 if(!m_walkflag(x2,y2,0, dir) && (abs(x2-Hero.getX())>=32 || abs(y2-Hero.getY())>=32))
12173 {
12174
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(addchild(x2,y2,get_qr(qr_ENEMIESZAXIS) ? 64 : 0,id2,-10, this->script_UID))
12175 {
12176 32 ((enemy*)guys.spr(kids+i))->count_enemy = false;
12177
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 25 times.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
32 if (get_qr(qr_ENEMIESZAXIS) && (((enemy*)guys.spr(kids+i))->moveflags & move_use_fake_z))
12178 {
12179 ((enemy*)guys.spr(kids+i))->fakez = 64;
12180 ((enemy*)guys.spr(kids+i))->z = 0;
12181 }
12182 32 }
12183
12184 32 summoned=true;
12185 32 break;
12186 }
12187 4 }
12188 32 }
12189
12190
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if(summoned)
12191 {
12192 17 sfx(firesfx, pan(int32_t(x)));
12193 17 }
12194 17 }
12195 17 }
12196 7900 }
12197
12198
12199 1019220 void eWizzrobe::wizzrobe_attack()
12200 {
12201
10/12
✓ Branch 0 taken 982487 times.
✓ Branch 1 taken 36733 times.
✓ Branch 2 taken 982487 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 937882 times.
✓ Branch 5 taken 44605 times.
✓ Branch 6 taken 934499 times.
✓ Branch 7 taken 3383 times.
✓ Branch 8 taken 932879 times.
✓ Branch 9 taken 1620 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 932879 times.
1019220 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
12202 86341 return;
12203
12204
3/8
✓ Branch 0 taken 893341 times.
✓ Branch 1 taken 39538 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 893341 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
932879 if(clk3<=0 || ((clk3&31)==0 && !canmove(dir,(zfix)1,spw_door,false) && !misc))
12205 {
12206 39538 fix_coords();
12207
12208
5/5
✓ Branch 0 taken 5496 times.
✓ Branch 1 taken 1050 times.
✓ Branch 2 taken 16081 times.
✓ Branch 3 taken 13008 times.
✓ Branch 4 taken 3903 times.
39538 switch(misc)
12209 {
12210 case 1: //walking
12211
2/2
✓ Branch 0 taken 10364 times.
✓ Branch 1 taken 2644 times.
13008 if(!m_walkflag(x,y,spw_door, dir))
12212 2644 misc=0;
12213 else
12214 {
12215 10364 clk3=16;
12216
12217
2/2
✓ Branch 0 taken 8966 times.
✓ Branch 1 taken 1398 times.
10364 if(!canmove(dir,(zfix)1,spw_wizzrobe,false))
12218 {
12219 1398 wizzrobe_newdir(0);
12220 1398 }
12221 }
12222
12223 13008 break;
12224
12225 case 2: //phasing
12226 {
12227 3903 int32_t jx=x;
12228 3903 int32_t jy=y;
12229 3903 int32_t jdir=-1;
12230
12231
5/5
✓ Branch 0 taken 1973 times.
✓ Branch 1 taken 484 times.
✓ Branch 2 taken 472 times.
✓ Branch 3 taken 482 times.
✓ Branch 4 taken 492 times.
3903 switch(zc_oldrand()&7)
12232 {
12233 case 0:
12234 484 jx-=32;
12235 484 jy-=32;
12236 484 jdir=15;
12237 484 break;
12238
12239 case 1:
12240 472 jx+=32;
12241 472 jy-=32;
12242 472 jdir=9;
12243 472 break;
12244
12245 case 2:
12246 482 jx+=32;
12247 482 jy+=32;
12248 482 jdir=11;
12249 482 break;
12250
12251 case 3:
12252 492 jx-=32;
12253 492 jy+=32;
12254 492 jdir=13;
12255 492 break;
12256 }
12257
12258
10/10
✓ Branch 0 taken 1930 times.
✓ Branch 1 taken 1973 times.
✓ Branch 2 taken 1724 times.
✓ Branch 3 taken 206 times.
✓ Branch 4 taken 1597 times.
✓ Branch 5 taken 127 times.
✓ Branch 6 taken 1385 times.
✓ Branch 7 taken 212 times.
✓ Branch 8 taken 1140 times.
✓ Branch 9 taken 245 times.
3903 if(jdir>0 && jx>=32 && jx<=208 && jy>=32 && jy<=128)
12259 {
12260 1140 misc=3;
12261 1140 clk3=32;
12262 1140 dir=jdir;
12263 1140 break;
12264 }
12265 2763 }
12266 [[fallthrough]];
12267 case 3:
12268 3813 dir&=3;
12269 3813 misc=0;
12270 [[fallthrough]];
12271 case 0:
12272 19894 wizzrobe_newdir(64);
12273 [[fallthrough]];
12274 default:
12275
2/2
✓ Branch 0 taken 21886 times.
✓ Branch 1 taken 3504 times.
25390 if(!canmove(dir,(zfix)1,spw_door,false))
12276 {
12277
2/2
✓ Branch 0 taken 3265 times.
✓ Branch 1 taken 239 times.
3504 if(canmove(dir,(zfix)15,spw_wizzrobe,false))
12278 {
12279 3265 misc=1;
12280 3265 clk3=16;
12281 3265 }
12282 else
12283 {
12284 239 wizzrobe_newdir(64);
12285 239 misc=0;
12286 239 clk3=32;
12287 }
12288 3504 }
12289 else
12290 {
12291 21886 clk3=32;
12292 }
12293
12294 25390 break;
12295 }
12296
12297
2/2
✓ Branch 0 taken 35060 times.
✓ Branch 1 taken 4478 times.
39538 if(misc<0)
12298 4478 ++misc;
12299 39538 }
12300
12301 932879 --clk3;
12302
12303
3/3
✓ Branch 0 taken 248377 times.
✓ Branch 1 taken 620599 times.
✓ Branch 2 taken 63903 times.
932879 switch(misc)
12304 {
12305 case 1:
12306 case 3:
12307 248377 step=1;
12308 248377 break;
12309
12310 case 2:
12311 63903 step=0;
12312 63903 break;
12313
12314 default:
12315 620599 step=0.5;
12316 620599 break;
12317
12318 }
12319
12320 932879 move(step);
12321
12322 // if(d->misc1 && misc<=0 && clk3==28)
12323
5/6
✓ Branch 0 taken 932879 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 620599 times.
✓ Branch 3 taken 312280 times.
✓ Branch 4 taken 599052 times.
✓ Branch 5 taken 21547 times.
932879 if(dmisc1 && misc<=0 && clk3==28)
12324 {
12325
2/2
✓ Branch 0 taken 16835 times.
✓ Branch 1 taken 4712 times.
21547 if(dmisc2 != 1)
12326 {
12327
2/2
✓ Branch 0 taken 14907 times.
✓ Branch 1 taken 1928 times.
16835 if(lined_up(8,false) == dir)
12328 {
12329 // addEwpn(x,y,z,wpn,0,wdp,dir,getUID());
12330 // sfx(WAV_WAND,pan(int32_t(x)));
12331 1928 wizzrobe_attack_for_real();
12332 1928 fclk=30;
12333 1928 }
12334 16835 }
12335 else
12336 {
12337
2/2
✓ Branch 0 taken 3717 times.
✓ Branch 1 taken 995 times.
4712 if((zc_oldrand()%500)>=400)
12338 {
12339 995 wizzrobe_attack_for_real();
12340 995 fclk=30;
12341 995 }
12342 }
12343 21547 }
12344
12345
4/4
✓ Branch 0 taken 517526 times.
✓ Branch 1 taken 415353 times.
✓ Branch 2 taken 4050 times.
✓ Branch 3 taken 513476 times.
932879 if(misc==0 && (zc_oldrand()&127)==0)
12346 4050 misc=2;
12347
12348
4/4
✓ Branch 0 taken 67953 times.
✓ Branch 1 taken 864926 times.
✓ Branch 2 taken 64512 times.
✓ Branch 3 taken 3441 times.
932879 if(misc==2 && clk3==4)
12349 3441 fix_coords();
12350
12351
2/4
✓ Branch 0 taken 932879 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 932879 times.
932879 if(!(charging||firing)) //should never be charging or firing for these wizzrobes
12352 {
12353
2/2
✓ Branch 0 taken 849597 times.
✓ Branch 1 taken 83282 times.
932879 if(fclk>0)
12354 {
12355 83282 --fclk;
12356 83282 }
12357 932879 }
12358
12359 1019220 }
12360
12361 21531 void eWizzrobe::wizzrobe_newdir(int32_t homing)
12362 {
12363 // Wizzrobes shouldn't move to the edge of the screen;
12364 // if they're already there, they should move toward the center
12365
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 21498 times.
21531 if(x<32)
12366 33 dir=right;
12367
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 21494 times.
21498 else if(x>=224)
12368 4 dir=left;
12369
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 21492 times.
21494 else if(y<32)
12370 2 dir=down;
12371
2/2
✓ Branch 0 taken 21487 times.
✓ Branch 1 taken 5 times.
21492 else if(y>=144)
12372 5 dir=up;
12373 else
12374 21487 newdir(4,homing,spw_wizzrobe);
12375 21531 }
12376
12377 2092991 void eWizzrobe::draw(BITMAP *dest)
12378 {
12379 // if(d->misc1 && (misc==1 || misc==3) && (clk3&1) && hp>0 && !watch && !stunclk) // phasing
12380
13/14
✓ Branch 0 taken 1042483 times.
✓ Branch 1 taken 1050508 times.
✓ Branch 2 taken 817873 times.
✓ Branch 3 taken 224610 times.
✓ Branch 4 taken 132112 times.
✓ Branch 5 taken 910371 times.
✓ Branch 6 taken 130752 times.
✓ Branch 7 taken 1360 times.
✓ Branch 8 taken 129926 times.
✓ Branch 9 taken 826 times.
✓ Branch 10 taken 125018 times.
✓ Branch 11 taken 4908 times.
✓ Branch 12 taken 125018 times.
✗ Branch 13 not taken.
2092991 if(dmisc1 && (misc==1 || misc==3) && (clk3&1) && hp>0 && !watch && !stunclk && !frozenclock) // phasing
12381 125018 return;
12382
12383 1967973 int32_t tempint=dummy_int[1];
12384 1967973 bool tempbool1=dummy_bool[1];
12385 1967973 bool tempbool2=dummy_bool[2];
12386 1967973 dummy_int[1]=fclk;
12387 1967973 dummy_bool[1]=charging;
12388 1967973 dummy_bool[2]=firing;
12389 1967973 update_enemy_frame();
12390 1967973 dummy_int[1]=tempint;
12391 1967973 dummy_bool[1]=tempbool1;
12392 1967973 dummy_bool[2]=tempbool2;
12393 1967973 enemy::draw(dest);
12394 2092991 }
12395
12396 203 eDodongo::eDodongo(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
12397 203 {
12398 203 fading=fade_flash_die;
12399
6/8
✓ Branch 0 taken 49 times.
✓ Branch 1 taken 154 times.
✓ Branch 2 taken 49 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 49 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3 times.
✓ Branch 7 taken 46 times.
203 if(dir==down&&y>=128)
12400 {
12401 3 dir=up;
12402 3 }
12403
12404
5/8
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 141 times.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 62 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 62 times.
203 if(dir==right&&x>=208)
12405 {
12406 dir=left;
12407 }
12408
1/4
✓ Branch 0 taken 203 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
203 if (SIZEflags != 0) init_size_flags();;
12409 203 }
12410
12411 125855 bool eDodongo::animate(int32_t index)
12412 {
12413
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125855 times.
125855 if(switch_hooked) return enemy::animate(index);
12414
2/2
✓ Branch 0 taken 3790 times.
✓ Branch 1 taken 122065 times.
125855 if(dying)
12415 {
12416 3790 return Dead(index);
12417 }
12418
12419
2/2
✓ Branch 0 taken 121496 times.
✓ Branch 1 taken 569 times.
122065 if(clk==0)
12420 {
12421 569 removearmos(x,y,ffcactivated);
12422 569 }
12423
12424
2/2
✓ Branch 0 taken 10848 times.
✓ Branch 1 taken 111217 times.
122065 if(clk2) // ate a bomb
12425 {
12426
2/2
✓ Branch 0 taken 10735 times.
✓ Branch 1 taken 113 times.
10848 if(--clk2==0)
12427 113 hp-=misc; // store bomb's power in misc
12428 10848 }
12429 else
12430 111217 constant_walk(rate,homing,spw_clipright);
12431
12432 122065 hit_width = (dir<=down) ? 16 : 32;
12433 // hysz = (dir>=left) ? 16 : 32;
12434
12435 122065 return enemy::animate(index);
12436 125855 }
12437
12438 125845 void eDodongo::draw(BITMAP *dest)
12439 {
12440 125845 tile=o_tile;
12441
12442
2/2
✓ Branch 0 taken 3065 times.
✓ Branch 1 taken 122780 times.
125845 if(clk<0)
12443 {
12444 3065 enemy::drawzcboss(dest);
12445 3065 return;
12446 }
12447
12448 122780 update_enemy_frame();
12449 122780 enemy::drawzcboss(dest);
12450
12451
2/2
✓ Branch 0 taken 51662 times.
✓ Branch 1 taken 71118 times.
122780 if(dummy_int[1]!=0) //additional tiles
12452 {
12453 71118 tile+=dummy_int[1]; //second tile is previous tile
12454 71118 xofs-=16; //new xofs change
12455 71118 enemy::drawzcboss(dest);
12456 71118 xofs+=16;
12457 71118 }
12458
12459 125845 }
12460
12461 8218 int32_t eDodongo::takehit(weapon *w, weapon* realweap)
12462 {
12463 8218 int32_t wpnId = w->id;
12464 8218 int32_t power = w->power;
12465 8218 int32_t wpnx = w->x;
12466 8218 int32_t wpny = w->y;
12467
12468
5/12
✓ Branch 0 taken 8218 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8218 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2457 times.
✓ Branch 5 taken 5761 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2457 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
8218 if(dying || clk<0 || clk2>0 || (superman && !(superman>1 && wpnId==wSBomb)))
12469 5761 return 0;
12470
12471
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 803 times.
✓ Branch 2 taken 1491 times.
✓ Branch 3 taken 17 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 146 times.
2457 switch(wpnId)
12472 {
12473 case wPhantom:
12474 return 0;
12475
12476 case wFire:
12477 case wBait:
12478 case wWhistle:
12479 case wWind:
12480 case wSSparkle:
12481 case wFSparkle:
12482 return 0;
12483
12484 case wLitBomb:
12485 case wLitSBomb:
12486
6/6
✓ Branch 0 taken 266 times.
✓ Branch 1 taken 537 times.
✓ Branch 2 taken 293 times.
✓ Branch 3 taken 510 times.
✓ Branch 4 taken 690 times.
✓ Branch 5 taken 113 times.
803 if(abs(wpnx-((dir==right)?x+16:x)) > 7 || abs(wpny-y) > 7)
12487 690 return 0;
12488
12489 113 clk2=96;
12490 113 misc=power;
12491
12492
2/2
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 3 times.
113 if(wpnId==wLitSBomb)
12493 3 item_set=isSBOMB100;
12494
12495 113 return 1;
12496
12497 case wBomb:
12498 case wSBomb:
12499
6/6
✓ Branch 0 taken 427 times.
✓ Branch 1 taken 1064 times.
✓ Branch 2 taken 420 times.
✓ Branch 3 taken 1071 times.
✓ Branch 4 taken 516 times.
✓ Branch 5 taken 975 times.
1491 if(abs(wpnx-((dir==right)?x+16:x)) > 8 || abs(wpny-y) > 8)
12500 516 return 0;
12501
12502 975 stunclk=160;
12503 975 misc=wpnId; // store wpnId
12504 975 return 1;
12505
12506 case wSword:
12507
2/2
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 88 times.
146 if(stunclk)
12508 {
12509 88 sfx(WAV_EHIT,pan(int32_t(x)));
12510 88 hp=0;
12511 88 item_set = (misc==wSBomb) ? isSBOMB100 : isBOMB100;
12512 88 fading=0; // don't flash
12513 88 return 1;
12514 }
12515
12516 [[fallthrough]];
12517 default:
12518 75 sfx(WAV_CHINK,pan(int32_t(x)));
12519 75 }
12520
12521 75 return 1;
12522 8218 }
12523
12524 48 eDodongo2::eDodongo2(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
12525 48 {
12526 48 fading=fade_flash_die;
12527 //nets+5180;
12528 48 previous_dir=-1;
12529
6/8
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 34 times.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 13 times.
48 if(dir==down&&y>=128)
12530 {
12531 1 dir=up;
12532 1 }
12533
12534
5/8
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 36 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 12 times.
48 if(dir==right&&x>=208)
12535 {
12536 dir=left;
12537 }
12538
1/4
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
48 if (SIZEflags != 0) init_size_flags();;
12539 48 }
12540
12541 39398 bool eDodongo2::animate(int32_t index)
12542 {
12543
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39398 times.
39398 if(switch_hooked) return enemy::animate(index);
12544
2/2
✓ Branch 0 taken 1158 times.
✓ Branch 1 taken 38240 times.
39398 if(dying)
12545 {
12546 1158 return Dead(index);
12547 }
12548
12549
2/2
✓ Branch 0 taken 38073 times.
✓ Branch 1 taken 167 times.
38240 if(clk==0)
12550 {
12551 167 removearmos(x,y,ffcactivated);
12552 167 }
12553
12554
2/2
✓ Branch 0 taken 4032 times.
✓ Branch 1 taken 34208 times.
38240 if(clk2) // ate a bomb
12555 {
12556
2/2
✓ Branch 0 taken 3990 times.
✓ Branch 1 taken 42 times.
4032 if(--clk2==0)
12557 42 hp-=misc; // store bomb's power in misc
12558 4032 }
12559 else
12560 34208 constant_walk(rate,homing,spw_clipbottomright);
12561
12562 38240 hit_width = (dir<=down) ? 16 : 32;
12563 38240 hit_height = (dir>=left) ? 16 : 32;
12564 38240 hxofs=(dir>=left)?-8:0;
12565 38240 hyofs=(dir<left)?-8:0;
12566
12567 38240 return enemy::animate(index);
12568 39398 }
12569
12570 39601 void eDodongo2::draw(BITMAP *dest)
12571 {
12572
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 38833 times.
39601 if(clk<0)
12573 {
12574 768 enemy::drawzcboss(dest);
12575 768 return;
12576 }
12577
12578 38833 int32_t tempx=xofs;
12579 38833 int32_t tempy=yofs;
12580 38833 update_enemy_frame();
12581 38833 enemy::drawzcboss(dest);
12582 38833 tile+=dummy_int[1]; //second tile change
12583 38833 xofs+=dummy_int[2]; //new xofs change
12584 38833 yofs+=dummy_int[3]; //new yofs change
12585 38833 enemy::drawzcboss(dest);
12586 38833 xofs=tempx;
12587 38833 yofs=tempy;
12588 39601 }
12589
12590 3929 int32_t eDodongo2::takehit(weapon *w, weapon* realweap)
12591 {
12592 3929 int32_t wpnId = w->id;
12593 3929 int32_t power = w->power;
12594 3929 int32_t wpnx = w->x;
12595 3929 int32_t wpny = w->y;
12596
12597
5/8
✓ Branch 0 taken 3929 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3929 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1552 times.
✓ Branch 5 taken 2377 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1552 times.
3929 if(dying || clk<0 || clk2>0 || superman)
12598 2377 return 0;
12599
12600
5/6
✓ Branch 0 taken 346 times.
✓ Branch 1 taken 321 times.
✓ Branch 2 taken 693 times.
✓ Branch 3 taken 31 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 161 times.
1552 switch(wpnId)
12601 {
12602 case wPhantom:
12603 return 0;
12604
12605 case wFire:
12606 case wBait:
12607 case wWhistle:
12608 case wWind:
12609 case wSSparkle:
12610 case wFSparkle:
12611 346 return 0;
12612
12613 case wLitBomb:
12614 case wLitSBomb:
12615
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 81 times.
321 switch(dir)
12616 {
12617 case up:
12618
4/4
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 4 times.
81 if(abs(wpnx-x) > 7 || abs(wpny-(y-8)) > 7)
12619 77 return 0;
12620
12621 4 break;
12622
12623 case down:
12624
4/4
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 38 times.
✓ Branch 2 taken 71 times.
✓ Branch 3 taken 6 times.
77 if(abs(wpnx-x) > 7 || abs(wpny-(y+8)) > 7)
12625 71 return 0;
12626
12627 6 break;
12628
12629 case left:
12630
4/4
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 40 times.
✓ Branch 2 taken 66 times.
✓ Branch 3 taken 16 times.
82 if(abs(wpnx-(x-8)) > 7 || abs(wpny-y) > 7)
12631 66 return 0;
12632
12633 16 break;
12634
12635 case right:
12636
4/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 65 times.
✓ Branch 2 taken 65 times.
✓ Branch 3 taken 16 times.
81 if(abs(wpnx-(x+8)) > 7 || abs(wpny-y) > 7)
12637 65 return 0;
12638
12639 16 break;
12640 }
12641
12642 // if(abs(wpnx-((dir==right)?x+8:(dir==left)?x-8:0)) > 7 || abs(wpny-((dir==down)?y+8:(dir==up)?y-8:0)) > 7)
12643 // return 0;
12644 42 clk2=96;
12645 42 misc=power;
12646
12647
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 if(wpnId==wLitSBomb)
12648 item_set=isSBOMB100;
12649
12650 42 return 1;
12651
12652 case wBomb:
12653 case wSBomb:
12654
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 176 times.
✓ Branch 2 taken 168 times.
✓ Branch 3 taken 185 times.
✓ Branch 4 taken 164 times.
693 switch(dir)
12655 {
12656 case up:
12657
4/4
✓ Branch 0 taken 121 times.
✓ Branch 1 taken 55 times.
✓ Branch 2 taken 84 times.
✓ Branch 3 taken 92 times.
176 if(abs(wpnx-x) > 7 || abs(wpny-(y-8)) > 7)
12658 84 return 0;
12659
12660 92 break;
12661
12662 case down:
12663
4/4
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 87 times.
✓ Branch 2 taken 113 times.
✓ Branch 3 taken 55 times.
168 if(abs(wpnx-x) > 7 || abs(wpny-(y+8)) > 7)
12664 113 return 0;
12665
12666 55 break;
12667
12668 case left:
12669
4/4
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 80 times.
✓ Branch 2 taken 80 times.
✓ Branch 3 taken 105 times.
185 if(abs(wpnx-(x-8)) > 7 || abs(wpny-y) > 7)
12670 80 return 0;
12671
12672 105 break;
12673
12674 case right:
12675
4/4
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 67 times.
✓ Branch 2 taken 71 times.
✓ Branch 3 taken 93 times.
164 if(abs(wpnx-(x+8)) > 7 || abs(wpny-y) > 7)
12676 71 return 0;
12677
12678 93 break;
12679 }
12680
12681 345 stunclk=160;
12682 345 misc=wpnId; // store wpnId
12683 345 return 1;
12684
12685 case wSword:
12686
2/2
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 34 times.
161 if(stunclk)
12687 {
12688 34 sfx(WAV_EHIT,pan(int32_t(x)));
12689 34 hp=0;
12690 34 item_set = (misc==wSBomb) ? isSBOMB100 : isBOMB100;
12691 34 fading=0; // don't flash
12692 34 return 1;
12693 }
12694
12695 [[fallthrough]];
12696 default:
12697 158 sfx(WAV_CHINK,pan(int32_t(x)));
12698 158 }
12699
12700 158 return 1;
12701 3929 }
12702
12703 126 eAquamentus::eAquamentus(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)//enemy((zfix)176,(zfix)64,Id,Clk)
12704 126 {
12705 //these are here to bypass compiler warnings about unused arguments
12706
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if ( !(editorflags & ENEMY_FLAG5) )
12707 {
12708
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 x = dmisc1 ? 64 : 176;
12709
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 y = 64;
12710 126 }
12711 else { x = X; y = Y; }
12712
12713 //nets+5940;
12714
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 45 times.
126 if(get_qr(qr_NEWENEMYTILES))
12715 {
12716 81 }
12717 else
12718 {
12719
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 7 times.
45 if(dmisc1)
12720 {
12721 7 flip=1;
12722 7 }
12723 }
12724
12725
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
126 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)+1;
12726 126 clk3=32;
12727 126 clk2=0;
12728 126 clk4=clk;
12729 126 dir=left;
12730
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
126 if (SIZEflags != 0) init_size_flags();;
12731 126 }
12732
12733 71899 bool eAquamentus::animate(int32_t index)
12734 {
12735
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 71899 times.
71899 if(switch_hooked) return enemy::animate(index);
12736
2/2
✓ Branch 0 taken 2092 times.
✓ Branch 1 taken 69807 times.
71899 if(dying)
12737 2092 return Dead(index);
12738
12739 // fbx=x+((id==eRAQUAM)?4:-4);
12740
2/2
✓ Branch 0 taken 69490 times.
✓ Branch 1 taken 317 times.
69807 if(clk==0)
12741 {
12742 317 removearmos(x,y,ffcactivated);
12743 317 }
12744
12745 69807 fbx=x;
12746
12747 /*
12748 if (get_qr(qr_NEWENEMYTILES)&&id==eLAQUAM)
12749 {
12750 fbx+=16;
12751 }
12752 */
12753
2/2
✓ Branch 0 taken 69357 times.
✓ Branch 1 taken 450 times.
69807 if(--clk3==0)
12754 {
12755 // addEwpn(fbx,y,z,ewFireball,0,d->wdp,up+1);
12756 // addEwpn(fbx,y,z,ewFireball,0,d->wdp,0);
12757 // addEwpn(fbx,y,z,ewFireball,0,d->wdp,down+1);
12758 450 addEwpn(fbx,y,z,wpn,2,wdp,up,getUID(), 0, fakez);
12759 450 addEwpn(fbx,y,z,wpn,2,wdp,8,getUID(), 0, fakez);
12760 450 addEwpn(fbx,y,z,wpn,2,wdp,down,getUID(), 0, fakez);
12761 450 sfx(wpnsfx(wpn),pan(int32_t(x)));
12762 450 }
12763
12764
4/4
✓ Branch 0 taken 21363 times.
✓ Branch 1 taken 48444 times.
✓ Branch 2 taken 345 times.
✓ Branch 3 taken 21018 times.
69807 if(clk3<-80 && !(zc_oldrand()&63))
12765 {
12766 345 clk3=32;
12767 345 }
12768
12769
2/2
✓ Branch 0 taken 68690 times.
✓ Branch 1 taken 1117 times.
69807 if(!((clk4+1)&63))
12770 {
12771 1117 int32_t d2=(zc_oldrand()%3)+1;
12772
12773
2/2
✓ Branch 0 taken 365 times.
✓ Branch 1 taken 752 times.
1117 if(d2>=left)
12774 {
12775 752 dir=d2;
12776 752 }
12777
12778
2/2
✓ Branch 0 taken 385 times.
✓ Branch 1 taken 732 times.
1117 if(dmisc1)
12779 {
12780
2/2
✓ Branch 0 taken 347 times.
✓ Branch 1 taken 38 times.
385 if(x<=40)
12781 {
12782 38 dir=right;
12783 38 }
12784
12785
1/2
✓ Branch 0 taken 385 times.
✗ Branch 1 not taken.
385 if(x>=104)
12786 {
12787 dir=left;
12788 }
12789 385 }
12790 else
12791 {
12792
2/2
✓ Branch 0 taken 711 times.
✓ Branch 1 taken 21 times.
732 if(x<=136)
12793 {
12794 21 dir=right;
12795 21 }
12796
12797
2/2
✓ Branch 0 taken 698 times.
✓ Branch 1 taken 34 times.
732 if(x>=200)
12798 {
12799 34 dir=left;
12800 34 }
12801 }
12802 1117 }
12803
12804
4/4
✓ Branch 0 taken 67907 times.
✓ Branch 1 taken 1900 times.
✓ Branch 2 taken 59366 times.
✓ Branch 3 taken 8541 times.
69807 if(clk4>=-1 && !((clk4+1)&7))
12805 {
12806
2/2
✓ Branch 0 taken 4546 times.
✓ Branch 1 taken 3995 times.
8541 if(dir==left)
12807 {
12808 4546 x-=1;
12809 4546 }
12810 else
12811 {
12812 3995 x+=1;
12813 }
12814 8541 }
12815
12816 69807 clk4=(clk4+1)%256;
12817
12818 69807 return enemy::animate(index);
12819 71899 }
12820
12821 72310 void eAquamentus::draw(BITMAP *dest)
12822 {
12823
2/2
✓ Branch 0 taken 44994 times.
✓ Branch 1 taken 27316 times.
72310 if(get_qr(qr_NEWENEMYTILES))
12824 {
12825 44994 xofs=(dmisc1?-16:0);
12826
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 44994 times.
✓ Branch 2 taken 18341 times.
✓ Branch 3 taken 26653 times.
44994 if ( do_animation ) tile=o_tile+((clk&24)>>2)+(clk3>-32?(clk3>0?40:80):0);
12827
12828
2/2
✓ Branch 0 taken 1312 times.
✓ Branch 1 taken 43682 times.
44994 if(dying)
12829 {
12830 1312 xofs=0;
12831 1312 enemy::draw(dest);
12832 1312 }
12833 else
12834 {
12835 43682 drawblock(dest,15);
12836 }
12837 44994 }
12838 else
12839 {
12840 27316 int32_t xblockofs=((dmisc1)?-16:16);
12841 27316 xofs=0;
12842
12843
4/4
✓ Branch 0 taken 26634 times.
✓ Branch 1 taken 682 times.
✓ Branch 2 taken 780 times.
✓ Branch 3 taken 25854 times.
27316 if(clk<0 || dying)
12844 {
12845 1462 enemy::draw(dest);
12846 1462 return;
12847 }
12848
1/2
✓ Branch 0 taken 25854 times.
✗ Branch 1 not taken.
25854 if ( do_animation )
12849 {
12850 // face (0=firing, 2=resting)
12851 25854 tile=o_tile+((clk3>0)?0:2);
12852 25854 enemy::draw(dest);
12853 // tail (
12854 25854 tile=o_tile+((clk&16)?1:3);
12855 25854 xofs=xblockofs;
12856 25854 enemy::draw(dest);
12857 // body
12858 25854 yofs+=16;
12859 25854 xofs=0;
12860 25854 tile=o_tile+((clk&16)?20:22);
12861 25854 enemy::draw(dest);
12862 25854 xofs=xblockofs;
12863 25854 tile=o_tile+((clk&16)?21:23);
12864 25854 enemy::draw(dest);
12865 25854 yofs-=16;
12866 25854 }
12867 else enemy::draw(dest);
12868 }
12869 72310 }
12870
12871 23834 bool eAquamentus::hit(weapon *w)
12872 {
12873
3/6
✓ Branch 0 taken 23834 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23834 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 23834 times.
23834 if(!w->scriptcoldet || w->fallclk || w->drownclk) return false;
12874
12875
2/2
✓ Branch 0 taken 4201 times.
✓ Branch 1 taken 19633 times.
23834 switch(w->id)
12876 {
12877 case wBeam:
12878 case wRefBeam:
12879 case wMagic:
12880 4201 hit_height=32;
12881 4201 }
12882
12883
4/4
✓ Branch 0 taken 22740 times.
✓ Branch 1 taken 1094 times.
✓ Branch 2 taken 17546 times.
✓ Branch 3 taken 5194 times.
23834 bool ret = (dying || hclk>0) ? false : sprite::hit(w);
12884 23834 hit_height=16;
12885 23834 return ret;
12886
12887 23834 }
12888
12889 93 eGohma::eGohma(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk) // enemy((zfix)128,(zfix)48,Id,0)
12890 93 {
12891
12892
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 if ( !(editorflags & ENEMY_FLAG5) )
12893 {
12894
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 x = 128;
12895
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 y = 48;
12896 93 }
12897 else { x = X; y = Y; }
12898
12899 93 Clk=Clk;
12900
2/4
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 93 times.
✗ Branch 3 not taken.
93 if(flags & guy_fade_flicker)
12901 {
12902 clk=0;
12903 superman = 1;
12904 fading=fade_flicker;
12905 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
12906 }
12907
3/4
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 51 times.
✓ Branch 3 taken 42 times.
93 else if(flags & guy_fade_instant)
12908 {
12909 42 clk=0;
12910 42 }
12911 93 hxofs=-16;
12912 93 hit_width=48;
12913 93 clk4=0;
12914
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 93 times.
✗ Branch 3 not taken.
93 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)+1;
12915
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 dir=zc_oldrand()%3+1;
12916
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
93 if (SIZEflags != 0) init_size_flags();;
12917
12918 //nets+5340;
12919 93 }
12920
12921 70891 bool eGohma::animate(int32_t index)
12922 {
12923
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70891 times.
70891 if(switch_hooked) return enemy::animate(index);
12924
2/2
✓ Branch 0 taken 1226 times.
✓ Branch 1 taken 69665 times.
70891 if(dying)
12925 1226 return Dead(index);
12926
12927
2/2
✓ Branch 0 taken 69629 times.
✓ Branch 1 taken 36 times.
69665 if(fading)
12928 {
12929
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 1 times.
36 if(++clk4 > 60)
12930 {
12931 35 clk4=0;
12932 35 superman=0;
12933 35 fading=0;
12934 35 clk=0;
12935
12936 35 }
12937 1 else return enemy::animate(index);
12938 35 }
12939
12940
2/2
✓ Branch 0 taken 69314 times.
✓ Branch 1 taken 350 times.
69664 if(clk==0)
12941 {
12942
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 350 times.
350 if (ffcactivated) removearmosffc(ffcactivated-1);
12943 else
12944 {
12945
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 350 times.
350 removearmos(zc_max(x-16, 0_zf),y);
12946 350 did_armos = false;
12947 350 removearmos(x,y);
12948 350 did_armos = false;
12949
1/2
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
350 removearmos(zc_min(x+16, 255_zf),y);
12950 }
12951 350 }
12952
12953
2/2
✓ Branch 0 taken 68878 times.
✓ Branch 1 taken 786 times.
69664 if(clk<0) return enemy::animate(index);
12954
12955 // Movement clk must be separate from animation clk because of the Clock item
12956
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68878 times.
68878 if(!watch)
12957 68878 clk4++;
12958
12959
2/2
✓ Branch 0 taken 67846 times.
✓ Branch 1 taken 1032 times.
68878 if((clk4&63)==0)
12960 {
12961
2/2
✓ Branch 0 taken 546 times.
✓ Branch 1 taken 486 times.
1032 if(clk4&64)
12962 546 dir^=1;
12963 else
12964 486 dir=zc_oldrand()%3+1;
12965 1032 }
12966
12967
2/2
✓ Branch 0 taken 67761 times.
✓ Branch 1 taken 1117 times.
68878 if((clk&63)==3)
12968 {
12969
2/2
✓ Branch 0 taken 882 times.
✓ Branch 1 taken 235 times.
1117 switch(dmisc1)
12970 {
12971 case 1:
12972 235 addEwpn(x,y+2,z,wpn,3,wdp,left,getUID(), 0, fakez);
12973 235 addEwpn(x,y+2,z,wpn,3,wdp,8,getUID(), 0, fakez);
12974 235 addEwpn(x,y+2,z,wpn,3,wdp,right,getUID(), 0, fakez);
12975 235 sfx(wpnsfx(wpn),pan(int32_t(x)));
12976 235 break;
12977
12978 default:
12979
3/4
✓ Branch 0 taken 882 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 128 times.
✓ Branch 3 taken 754 times.
882 if(dmisc1 != 1 && dmisc1 != 2)
12980 {
12981 754 addEwpn(x,y+2,z,wpn,3,wdp,8,getUID(), 0, fakez);
12982 754 sfx(wpnsfx(wpn),pan(int32_t(x)));
12983 754 sfx(wpnsfx(wpn),pan(int32_t(x)));
12984 754 }
12985
12986 882 break;
12987 }
12988 1117 }
12989
12990
6/6
✓ Branch 0 taken 8027 times.
✓ Branch 1 taken 60851 times.
✓ Branch 2 taken 7611 times.
✓ Branch 3 taken 416 times.
✓ Branch 4 taken 5396 times.
✓ Branch 5 taken 2215 times.
68878 if((dmisc1 == 2)&& clk3>=16 && clk3<116)
12991 {
12992
2/2
✓ Branch 0 taken 290 times.
✓ Branch 1 taken 1925 times.
2215 if(!(clk3%8))
12993 {
12994 290 FireBreath(true);
12995 290 }
12996 2215 }
12997
12998
2/2
✓ Branch 0 taken 34399 times.
✓ Branch 1 taken 34479 times.
68878 if(clk4&1)
12999 34479 move((zfix)1);
13000
13001
2/2
✓ Branch 0 taken 68728 times.
✓ Branch 1 taken 150 times.
68878 if(++clk3>=400)
13002 150 clk3=0;
13003
13004 68878 return enemy::animate(index);
13005 70891 }
13006
13007 70889 void eGohma::draw(BITMAP *dest)
13008 {
13009 70889 tile=o_tile;
13010
13011
4/4
✓ Branch 0 taken 70103 times.
✓ Branch 1 taken 786 times.
✓ Branch 2 taken 1226 times.
✓ Branch 3 taken 68877 times.
70889 if(clk<0 || dying)
13012 {
13013 2012 enemy::drawzcboss(dest);
13014 2012 return;
13015 }
13016
13017
2/2
✓ Branch 0 taken 53472 times.
✓ Branch 1 taken 15405 times.
68877 if(get_qr(qr_NEWENEMYTILES))
13018 {
13019 ///if ( do_animation )
13020 //Yuck. Gohma can just not have this capability right now.
13021 // left side
13022 53472 xofs=-16;
13023 53472 flip=0;
13024 // if(clk&16) tile=180;
13025 // else { tile=182; flip=1; }
13026 53472 tile+=(3*((clk&48)>>4));
13027 53472 enemy::drawzcboss(dest);
13028
13029 // right side
13030 53472 xofs=16;
13031 // tile=(180+182)-tile;
13032 53472 tile=o_tile;
13033 53472 tile+=(3*((clk&48)>>4))+2;
13034 53472 enemy::drawzcboss(dest);
13035
13036 // body
13037 53472 xofs=0; //Gohma may need more adjustments for SIZEflags. -Z 14 Aug 2020
13038 53472 tile=o_tile;
13039
13040 // tile+=(3*((clk&24)>>3))+2;
13041
2/2
✓ Branch 0 taken 2975 times.
✓ Branch 1 taken 50497 times.
53472 if(clk3<16)
13042 2975 tile+=7;
13043
2/2
✓ Branch 0 taken 15890 times.
✓ Branch 1 taken 34607 times.
50497 else if(clk3<116)
13044 15890 tile+=10;
13045
2/2
✓ Branch 0 taken 2051 times.
✓ Branch 1 taken 32556 times.
34607 else if(clk3<132)
13046 2051 tile+=7;
13047 else
13048 32556 tile+=((clk3-132)&24)?4:1;
13049
13050 53472 enemy::drawzcboss(dest);
13051
13052 53472 }
13053 else
13054 {
13055 // left side
13056 15405 xofs=-16;
13057 15405 flip=0;
13058
13059
2/2
✓ Branch 0 taken 7615 times.
✓ Branch 1 taken 7790 times.
15405 if(!(clk&16))
13060 {
13061 7790 tile+=2;
13062 7790 flip=1;
13063 7790 }
13064
13065 15405 enemy::draw(dest);
13066
13067 // right side
13068 15405 tile=o_tile;
13069 15405 xofs=16;
13070
13071
2/2
✓ Branch 0 taken 7790 times.
✓ Branch 1 taken 7615 times.
15405 if((clk&16)) tile+=2;
13072
13073 // tile=(180+182)-tile;
13074 15405 enemy::draw(dest);
13075
13076 // body
13077 15405 tile=o_tile;
13078 15405 xofs=0;
13079
13080
2/2
✓ Branch 0 taken 912 times.
✓ Branch 1 taken 14493 times.
15405 if(clk3<16)
13081 912 tile+=4;
13082
2/2
✓ Branch 0 taken 4882 times.
✓ Branch 1 taken 9611 times.
14493 else if(clk3<116)
13083 4882 tile+=5;
13084
2/2
✓ Branch 0 taken 585 times.
✓ Branch 1 taken 9026 times.
9611 else if(clk3<132)
13085 585 tile+=4;
13086 9026 else tile+=((clk3-132)&8)?3:1;
13087
13088 15405 enemy::draw(dest);
13089
13090 }
13091 70889 }
13092
13093 578 int32_t eGohma::takehit(weapon *w, weapon* realweap)
13094 {
13095 578 int32_t wpnId = w->id;
13096 578 int32_t power = w->power;
13097 578 int32_t wpnx = w->x;
13098 578 int32_t wpnDir = w->dir;
13099 578 int32_t def = defenditemclassNew(wpnId, &power, w, realweap);
13100
13101
2/2
✓ Branch 0 taken 157 times.
✓ Branch 1 taken 421 times.
578 if(def < 0)
13102 {
13103
7/10
✗ Branch 0 not taken.
✓ Branch 1 taken 421 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 367 times.
✓ Branch 5 taken 54 times.
✓ Branch 6 taken 364 times.
✓ Branch 7 taken 3 times.
✓ Branch 8 taken 328 times.
✓ Branch 9 taken 36 times.
421 if(!((wpnDir==up || wpnDir==l_up || wpnDir==r_up) && abs(int32_t(x)-wpnx)<=8 && clk3>=16 && clk3<116))
13104 {
13105 93 sfx(WAV_CHINK,pan(int32_t(x)));
13106 93 return 1;
13107 }
13108 328 }
13109
13110 485 return enemy::takehit(w, realweap);
13111 578 }
13112
13113 327 eLilDig::eLilDig(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13114 327 {
13115 327 count_enemy=(id==(id&0xFFF));
13116 //nets+4360+(((id&0xFF)-eDIGPUP2)*40);
13117
1/4
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
327 if (SIZEflags != 0) init_size_flags();;
13118 327 }
13119
13120 124050 bool eLilDig::animate(int32_t index)
13121 {
13122
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124050 times.
124050 if(switch_hooked) return enemy::animate(index);
13123
2/2
✓ Branch 0 taken 4410 times.
✓ Branch 1 taken 119640 times.
124050 if(dying)
13124 4410 return Dead(index);
13125
13126
2/2
✓ Branch 0 taken 7105 times.
✓ Branch 1 taken 112535 times.
119640 if(clk==0)
13127 {
13128 7105 removearmos(x,y,ffcactivated);
13129 7105 }
13130
13131
2/2
✓ Branch 0 taken 80994 times.
✓ Branch 1 taken 38646 times.
119640 if(misc<=128)
13132 {
13133
2/2
✓ Branch 0 taken 1161 times.
✓ Branch 1 taken 37485 times.
38646 if(!(++misc&31))
13134 1161 step+=0.25;
13135 38646 }
13136
13137 119640 variable_walk_8(rate,homing,hrate,spw_floater);
13138 119640 return enemy::animate(index);
13139 124050 }
13140
13141 124268 void eLilDig::draw(BITMAP *dest)
13142 {
13143 124268 tile = o_tile;
13144 // tile = 160;
13145 124268 int32_t fdiv = frate/4;
13146
1/2
✓ Branch 0 taken 124268 times.
✗ Branch 1 not taken.
124268 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
13147
2/2
✓ Branch 0 taken 91457 times.
✓ Branch 1 taken 32811 times.
124268 int32_t f2=get_qr(qr_NEWENEMYTILES)?
13148 124268 efrate:((clk>=(frate>>1))?1:0);
13149
13150
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124268 times.
124268 if ( do_animation )
13151 {
13152
2/2
✓ Branch 0 taken 91457 times.
✓ Branch 1 taken 32811 times.
124268 if(get_qr(qr_NEWENEMYTILES))
13153 {
13154
9/9
✓ Branch 0 taken 11370 times.
✓ Branch 1 taken 10699 times.
✓ Branch 2 taken 10722 times.
✓ Branch 3 taken 12015 times.
✓ Branch 4 taken 10070 times.
✓ Branch 5 taken 9554 times.
✓ Branch 6 taken 8255 times.
✓ Branch 7 taken 10033 times.
✓ Branch 8 taken 8739 times.
91457 switch(dir-8) //directions get screwed up after 8. *shrug*
13155 {
13156 case up: //u
13157 11370 flip=0;
13158 11370 break;
13159
13160 case l_up: //d
13161 10699 flip=0;
13162 10699 tile+=4;
13163 10699 break;
13164
13165 case l_down: //l
13166 10722 flip=0;
13167 10722 tile+=8;
13168 10722 break;
13169
13170 case left: //r
13171 12015 flip=0;
13172 12015 tile+=12;
13173 12015 break;
13174
13175 case r_down: //ul
13176 10070 flip=0;
13177 10070 tile+=20;
13178 10070 break;
13179
13180 case down: //ur
13181 9554 flip=0;
13182 9554 tile+=24;
13183 9554 break;
13184
13185 case r_up: //dl
13186 8255 flip=0;
13187 8255 tile+=28;
13188 8255 break;
13189
13190 case right: //dr
13191 10033 flip=0;
13192 10033 tile+=32;
13193 10033 break;
13194 }
13195
13196 91457 tile+=f2;
13197 91457 }
13198 else
13199 {
13200 32811 tile+=(clk>=6)?1:0;
13201 }
13202 124268 }
13203
13204 124268 enemy::draw(dest);
13205 124268 }
13206
13207 80 eBigDig::eBigDig(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13208 80 {
13209
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 init_size_flags();
13210 80 }
13211
13212 29662 bool eBigDig::animate(int32_t index)
13213 {
13214
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29662 times.
29662 if(switch_hooked) return enemy::animate(index);
13215
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29662 times.
29662 if(dying)
13216 return Dead(index);
13217
13218
2/2
✓ Branch 0 taken 25558 times.
✓ Branch 1 taken 4104 times.
29662 if(clk==0)
13219 {
13220 4104 removearmos(x,y,ffcactivated);
13221 4104 }
13222
13223
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 29534 times.
✓ Branch 2 taken 64 times.
✓ Branch 3 taken 64 times.
29662 switch(misc)
13224 {
13225 case 0:
13226 29534 variable_walk_8(rate,homing,hrate,spw_floater,-8,-16,23,23);
13227 29534 break;
13228
13229 case 1:
13230 64 ++misc;
13231 64 break;
13232
13233 case 2:
13234
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 64 times.
175 for(int32_t i=0; i<dmisc5; i++)
13235 {
13236 111 addenemy(x,y,dmisc1+0x1000,-15);
13237 111 }
13238
13239
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 64 times.
94 for(int32_t i=0; i<dmisc6; i++)
13240 {
13241 30 addenemy(x,y,dmisc2+0x1000,-15);
13242 30 }
13243
13244
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 64 times.
94 for(int32_t i=0; i<dmisc7; i++)
13245 {
13246 30 addenemy(x,y,dmisc3+0x1000,-15);
13247 30 }
13248
13249
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 64 times.
94 for(int32_t i=0; i<dmisc8; i++)
13250 {
13251 30 addenemy(x,y,dmisc4+0x1000,-15);
13252 30 }
13253
13254
2/2
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 2 times.
64 if(itemguy) // Hand down the carried item
13255 {
13256 2 guycarryingitem = guys.Count()-1;
13257 2 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
13258 2 itemguy = false;
13259 2 }
13260
13261 64 stop_bgsfx(index);
13262
13263
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
64 if(deadsfx > 0) sfx(deadsfx,pan(int32_t(x)));
13264
13265 64 return true;
13266 }
13267
13268 29598 return enemy::animate(index);
13269 29662 }
13270
13271 29658 void eBigDig::draw(BITMAP *dest)
13272 {
13273
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29658 times.
29658 if(anim!=aDIG)
13274 {
13275 update_enemy_frame();
13276 xofs-=8;
13277 yofs-=8;
13278 drawblock(dest,15);
13279 xofs+=8;
13280 yofs+=8;
13281 return;
13282 }
13283
13284 29658 tile = o_tile;
13285 29658 int32_t fdiv = frate/4;
13286
1/2
✓ Branch 0 taken 29658 times.
✗ Branch 1 not taken.
29658 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
13287
13288
2/2
✓ Branch 0 taken 16161 times.
✓ Branch 1 taken 13497 times.
29658 int32_t f2=get_qr(qr_NEWENEMYTILES)?
13289 29658 efrate:((clk>=(frate>>1))?1:0);
13290
13291
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29658 times.
29658 if ( do_animation )
13292 {
13293
2/2
✓ Branch 0 taken 16161 times.
✓ Branch 1 taken 13497 times.
29658 if(get_qr(qr_NEWENEMYTILES))
13294 {
13295
9/9
✓ Branch 0 taken 1688 times.
✓ Branch 1 taken 1684 times.
✓ Branch 2 taken 2031 times.
✓ Branch 3 taken 1910 times.
✓ Branch 4 taken 2041 times.
✓ Branch 5 taken 2043 times.
✓ Branch 6 taken 1514 times.
✓ Branch 7 taken 1009 times.
✓ Branch 8 taken 2241 times.
16161 switch(dir-8) //directions get screwed up after 8. *shrug*
13296 {
13297 case up: //u
13298 1688 flip=0;
13299 1688 break;
13300
13301 case l_up: //d
13302 1684 flip=0;
13303 1684 tile+=8;
13304 1684 break;
13305
13306 case l_down: //l
13307 2031 flip=0;
13308 2031 tile+=40;
13309 2031 break;
13310
13311 case left: //r
13312 1910 flip=0;
13313 1910 tile+=48;
13314 1910 break;
13315
13316 case r_down: //ul
13317 2041 flip=0;
13318 2041 tile+=80;
13319 2041 break;
13320
13321 case down: //ur
13322 2043 flip=0;
13323 2043 tile+=88;
13324
13325 2043 break;
13326
13327 case r_up: //dl
13328 1514 flip=0;
13329 1514 tile+=120;
13330 1514 break;
13331
13332 case right: //dr
13333 2241 flip=0;
13334 2241 tile+=128;
13335 2241 break;
13336 }
13337
13338 16161 tile+=(f2*2);
13339 16161 }
13340 else
13341 {
13342 13497 tile+=(f2)?0:2;
13343 13497 flip=(clk&1)?1:0;
13344 }
13345 29658 }
13346
13347 29658 xofs-=8;
13348 29658 yofs-=8;
13349 29658 drawblock(dest,15);
13350 29658 xofs+=8;
13351 29658 yofs+=8;
13352 29658 }
13353
13354 869 int32_t eBigDig::takehit(weapon *w, weapon* realweap)
13355 {
13356 869 int32_t wpnId = w->id;
13357
13358
3/4
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 805 times.
✓ Branch 2 taken 64 times.
✗ Branch 3 not taken.
869 if(wpnId==wWhistle && misc==0)
13359 64 misc=1;
13360
13361 869 return 0;
13362 }
13363
13364 80 void eBigDig::init_size_flags()
13365 {
13366 80 SIZEflags = d->SIZEflags;
13367
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
80 if (((SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
13368 // al_trace("Enemy txsz:%i\n", txsz);
13369
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
80 if (((SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
13370
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
80 if (((SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0) hit_width = d->hxsz;
13371 80 else hit_width = 32;
13372
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
80 if (((SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0) hit_height = d->hysz;
13373 80 else hit_height = 32;
13374
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
80 if (((SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0) hzsz = d->hzsz;
13375 80 else hzsz = 16; // hard to jump.
13376
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
80 if ((SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
13377 80 else hxofs = -8;
13378
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
80 if ((SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
13379 80 else hyofs = -8;
13380 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
13381
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 if ((SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = d->xofs;
13382
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 if ((SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
13383 {
13384 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
13385 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
13386 }
13387
13388
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 if ((SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = d->zofs;
13389 80 }
13390
13391 /*
13392 eGanon::eGanon(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13393 {
13394 hxofs=hyofs=8;
13395 hzsz=16; //can't be jumped.
13396 clk2=70;
13397 misc=-1;
13398 mainguy=!getmapflag();
13399 }
13400
13401 bool eGanon::animate(int32_t index)
13402 {
13403 if(switch_hooked) return enemy::animate(index);
13404 if(dying)
13405
13406 return Dead(index);
13407
13408 if(clk==0)
13409 {
13410 removearmos(x,y,ffcactivated);
13411 }
13412
13413 switch(misc)
13414 {
13415 case -1:
13416 misc=0;
13417
13418 case 0:
13419 if(++clk2>72 && !(zc_oldrand()&3))
13420 {
13421 addEwpn(x,y,z,wpn,3,wdp,dir,getUID());
13422 sfx(wpnsfx(wpn),pan(int32_t(x)));
13423 clk2=0;
13424 }
13425
13426 Stunclk=0;
13427 constant_walk(rate,homing,spw_none);
13428 break;
13429
13430 case 1:
13431 case 2:
13432 if(--Stunclk<=0)
13433 {
13434 int32_t r=zc_oldrand();
13435
13436 if(r&1)
13437 {
13438 y=96;
13439
13440 if(r&2)
13441 x=160;
13442 else
13443 x=48;
13444
13445 if(tooclose(x,y,48))
13446 x=208-x;
13447 }
13448
13449 //if ( editorflags & ENEMY_FLAG15 && current_item_id(itype_amulet,false) >= 2 ) //visible to Amulet 2
13450 //{
13451 // loadpalset(9,pSprite(spBROWN)); //make Ganon visible?
13452 // }
13453 // else
13454 // {
13455 loadpalset(csBOSS,pSprite(d->bosspal));
13456 // }
13457 misc=0;
13458 }
13459
13460 break;
13461
13462 case 3:
13463 {
13464 if(hclk>0)
13465 break;
13466
13467 misc=4;
13468 clk=0;
13469 hxofs=1000;
13470 loadpalset(9,pSprite(spPILE));
13471 music_stop();
13472 stop_sfx(WAV_ROAR);
13473
13474 if(deadsfx>0) sfx(deadsfx,pan(int32_t(x)));
13475
13476 sfx(WAV_GANON);
13477 //Ganon's dustpile; fall in sideview. -Z
13478 item *dustpile = new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0);
13479 dustpile->linked_parent = eeGANON;
13480 setmapflag();
13481 //items.add(new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0));
13482 break;
13483 }
13484
13485 case 4:
13486 if(clk>=80)
13487 {
13488 misc=5;
13489
13490 if(getmapflag())
13491 {
13492 game->lvlitems[dlevel]|=liBOSS;
13493 //play_DmapMusic();
13494 playLevelMusic();
13495 return true;
13496 }
13497
13498 sfx(WAV_CLEARED);
13499 items.add(new item(x+8,y+8,(zfix)0,iBigTri,ipBIGTRI,0));
13500 setmapflag();
13501 }
13502
13503 break;
13504 }
13505
13506 //if ( editorflags & ENEMY_FLAG15 ) //visible to Amulet 2
13507 //{
13508 //if ( current_item_id(itype_amulet,false) >= 2 )
13509 //{
13510 /// loadpalset(9,pSprite(spBROWN)); //make Ganon visible?
13511 //}
13512 //}
13513
13514
13515 return enemy::animate(index);
13516 }
13517
13518
13519 int32_t eGanon::takehit(weapon *w, weapon* realweap)
13520 {
13521 //these are here to bypass compiler warnings about unused arguments
13522 int32_t wpnId = w->id;
13523 int32_t power = w->power;
13524 int32_t enemyHitWeapon = w->parentitem;
13525
13526 switch(misc)
13527 {
13528 case 0:
13529 {
13530 //if we're not using the editor defences, and Ganon isn't hit by a sword, return.
13531 if(wpnId!=wSword && !(editorflags & ENEMY_FLAG14))
13532 return 0;
13533
13534 //if we are not using the new defences, just reduce his HP
13535 if (!(editorflags & ENEMY_FLAG14))
13536 {
13537 hp-=power;
13538 if(hp>0)
13539 {
13540 misc=1;
13541 Stunclk=64;
13542 }
13543 else
13544 {
13545 loadpalset(csBOSS,pSprite(spBROWN));
13546 misc=2;
13547 Stunclk=284;
13548 hp=guysbuf[id&0xFFF].hp; //16*game->get_hero_dmgmult();
13549 }
13550
13551 sfx(WAV_EHIT,pan(int32_t(x)));
13552
13553 if(hitsfx>0) sfx(hitsfx,pan(int32_t(x)));
13554
13555 return 1;
13556 }
13557 //otherwise, resolve his defence.
13558 else
13559 {
13560 int32_t def = enemy::takehit(w,realweap); //This works, but it instantly kills him if it does enough damage.
13561 if(hp>0)
13562 {
13563 misc=1;
13564 Stunclk=64;
13565 }
13566 else
13567 {
13568 loadpalset(csBOSS,pSprite(spBROWN));
13569 misc=2;
13570 Stunclk=284;
13571 hp=guysbuf[id&0xFFF].hp; //16*game->get_hero_dmgmult();
13572 }
13573
13574 sfx(WAV_EHIT,pan(int32_t(x)));
13575
13576 if(hitsfx>0) sfx(hitsfx,pan(int32_t(x)));
13577
13578
13579 return 1;
13580 }
13581 }
13582 case 2:
13583 {
13584 if
13585 (
13586 ( dmisc14 > 0 && !enemyHitWeapon == dmisc14 ) //special weapon needed to kill ganon specified in editor
13587 || //or nothing specified, use silver arrows+
13588 ( dmisc14 <= 0 && (wpnId!=wArrow || (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_arrow))<4))
13589 )
13590 return 0;
13591 {
13592 misc=3;
13593 hclk=81;
13594 loadpalset(9,pSprite(spBROWN));
13595 return 1;
13596 }
13597
13598 }
13599 }
13600
13601 return 0;
13602 }
13603
13604 void eGanon::draw(BITMAP *dest)
13605 {
13606 switch(misc)
13607 {
13608 case 0:
13609 if((clk&3)==3)
13610 tile=(zc_oldrand()%5)*2+o_tile;
13611
13612 if(db!=999)
13613 break;
13614
13615 case 2:
13616 if(Stunclk<64 && (Stunclk&1) )
13617 {
13618 if
13619 (
13620 ( (editorflags & ENEMY_FLAG1) && current_item_power(itype_amulet) >= 2 && (editorflags & ENEMY_FLAG15) )
13621 ||
13622 ( (editorflags & ENEMY_FLAG2) && (game->item[dmisc13]) && (editorflags & ENEMY_FLAG15) )
13623 )
13624 {
13625 goto ganon_draw; //draw his weapons if we can see him
13626 }
13627 break;
13628 }
13629
13630 case -1:
13631 tile=o_tile;
13632
13633 //fall through
13634 case 1:
13635 case 3:
13636 ganon_draw:
13637 drawblock(dest,15);
13638 break;
13639
13640 case 4:
13641 draw_guts(dest);
13642 draw_flash(dest);
13643 break;
13644 }
13645
13646 if ( editorflags & ENEMY_FLAG1 ) //visible to Amulet 2
13647 {
13648 if
13649 (
13650 ( (editorflags & ENEMY_FLAG1) && current_item_power(itype_amulet) >= 2 && (editorflags & ENEMY_FLAG15) )
13651 ||
13652 ( (editorflags & ENEMY_FLAG2) && (game->item[dmisc13]) && (editorflags & ENEMY_FLAG15) )
13653 )
13654 {
13655 draw_guts(dest); //makes his shots visible, but not him
13656 draw_flash(dest);
13657 }
13658 }
13659 }
13660
13661 void eGanon::draw_guts(BITMAP *dest)
13662 {
13663 int32_t c = zc_min(clk>>3,8);
13664 tile = clk<24 ? 74 : 75;
13665 overtile16(dest,tile,x+8,y+c+playing_field_offset,9,0);
13666 overtile16(dest,tile,x+8,y+16-c+playing_field_offset,9,0);
13667 overtile16(dest,tile,x+c,y+8+playing_field_offset,9,0);
13668 overtile16(dest,tile,x+16-c,y+8+playing_field_offset,9,0);
13669 overtile16(dest,tile,x+c,y+c+playing_field_offset,9,0);
13670 overtile16(dest,tile,x+16-c,y+c+playing_field_offset,9,0);
13671 overtile16(dest,tile,x+c,y+16-c+playing_field_offset,9,0);
13672 overtile16(dest,tile,x+16-c,y+16-c+playing_field_offset,9,0);
13673 }
13674
13675 void eGanon::draw_flash(BITMAP *dest)
13676 {
13677
13678 int32_t c = clk-(clk>>2);
13679 cs = (frame&3)+6;
13680 overtile16(dest,194,x+8,y+8-clk+playing_field_offset,cs,0);
13681 overtile16(dest,194,x+8,y+8+clk+playing_field_offset,cs,2);
13682 overtile16(dest,195,x+8-clk,y+8+playing_field_offset,cs,0);
13683 overtile16(dest,195,x+8+clk,y+8+playing_field_offset,cs,1);
13684 overtile16(dest,196,x+8-c,y+8-c+playing_field_offset,cs,0);
13685 overtile16(dest,196,x+8+c,y+8-c+playing_field_offset,cs,1);
13686 overtile16(dest,196,x+8-c,y+8+c+playing_field_offset,cs,2);
13687 overtile16(dest,196,x+8+c,y+8+c+playing_field_offset,cs,3);
13688 }
13689 */
13690
13691 13 eGanon::eGanon(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13692 13 {
13693 13 hxofs=hyofs=8;
13694
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if (editorflags & ENEMY_FLAG3)
13695 {
13696 hxofs = 4;
13697 hyofs = 4;
13698 hit_width = 24;
13699 hit_height = 24;
13700 SIZEflags|=OVERRIDE_HIT_WIDTH;
13701 SIZEflags|=OVERRIDE_HIT_HEIGHT;
13702 }
13703 13 hzsz=16; //can't be jumped.
13704 13 clk2=70;
13705 13 misc=-1;
13706
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13 times.
✗ Branch 5 not taken.
13 mainguy=(!getmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN));
13707 13 }
13708
13709 18254 bool eGanon::animate(int32_t index) //DO NOT ADD a check for do_animation to this version of GANON!! -Z
13710 {
13711
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18254 times.
18254 if(dying)
13712
13713 return Dead(index);
13714
13715
2/2
✓ Branch 0 taken 18182 times.
✓ Branch 1 taken 72 times.
18254 if(clk==0)
13716 {
13717 72 removearmos(x,y,ffcactivated);
13718 72 }
13719
13720
6/7
✓ Branch 0 taken 3607 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12680 times.
✓ Branch 3 taken 13 times.
✓ Branch 4 taken 984 times.
✓ Branch 5 taken 960 times.
✓ Branch 6 taken 10 times.
18254 switch(misc)
13721 {
13722 case -1:
13723 13 misc=0;
13724 [[fallthrough]];
13725 case 0:
13726
4/4
✓ Branch 0 taken 708 times.
✓ Branch 1 taken 11985 times.
✓ Branch 2 taken 535 times.
✓ Branch 3 taken 173 times.
12693 if(++clk2>72 && !(zc_oldrand()&3))
13727 {
13728 173 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
13729 173 sfx(wpnsfx(wpn),pan(int32_t(x)));
13730 173 clk2=0;
13731 173 }
13732
13733 12693 Stunclk=0;
13734 12693 constant_walk(rate,homing,spw_none);
13735 12693 break;
13736
13737 case 1:
13738 case 2:
13739
2/2
✓ Branch 0 taken 3566 times.
✓ Branch 1 taken 41 times.
3607 if(--Stunclk<=0)
13740 {
13741 41 int32_t r=zc_oldrand();
13742
13743
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 17 times.
41 if(r&1)
13744 {
13745 17 y=96;
13746
13747
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 11 times.
17 if(r&2)
13748 6 x=160;
13749 else
13750 11 x=48;
13751
13752
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 8 times.
17 if(tooclose(x,y,48))
13753 8 x=208-x;
13754 17 }
13755
13756 41 loadpalset(csBOSS,pSprite(d->bosspal));
13757 41 misc=0;
13758 41 }
13759
13760 3607 break;
13761
13762 case 3:
13763 {
13764
2/2
✓ Branch 0 taken 972 times.
✓ Branch 1 taken 12 times.
984 if(hclk>0)
13765 972 break;
13766
13767 12 misc=4;
13768 12 clk=0;
13769 12 hxofs=1000;
13770 12 loadpalset(9,pSprite(spPILE));
13771 12 music_stop();
13772 12 stop_sfx(WAV_ROAR);
13773
13774
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(deadsfx>0) sfx(deadsfx,pan(int32_t(x)));
13775
13776 12 sfx(WAV_GANON);
13777 //Ganon's dustpile; fall in sideview. -Z
13778 //item *dustpile = new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0);
13779 //dustpile->miscellaneous[31] = eeGANON;
13780
6/12
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 12 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 12 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 12 times.
✗ Branch 11 not taken.
12 items.add(new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0));
13781 12 item *dustpile = NULL;
13782 //dustpile = (item *)items.spr(items.Count() - 1)->getUID();
13783 12 dustpile = (item *)items.spr(items.Count() - 1);
13784 12 dustpile->linked_parent = eeGANON; //was miscellaneous[31]
13785 //setmapflag(); //Could be why the Triforce doesn't drop. Disabling this now. -Z ( 6th March, 2019 )
13786 //items.add(new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0));
13787 12 break;
13788 }
13789
13790 case 4:
13791
2/2
✓ Branch 0 taken 948 times.
✓ Branch 1 taken 12 times.
960 if(clk>=80)
13792 {
13793 12 misc=5;
13794
13795 //game->lvlitems[dlevel]|=liBOSS;
13796
13797 12 sfx(WAV_CLEARED);
13798 //Add the big TF over the ashes!
13799
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 12 times.
36 for(word q = 0; q < items.Count(); q++)
13800 {
13801 24 item *ashes = (item*)items.spr(q);
13802
3/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✓ Branch 3 taken 12 times.
24 if ( ashes->linked_parent == eeGANON && (ashes->pickup&ipDUMMY))
13803 {
13804 //Z_scripterrlog("Found correct dustpile!\n");
13805
4/8
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 12 times.
✗ Branch 7 not taken.
12 items.add(new item(ashes->x,ashes->y,(zfix)0,iBigTri,ipBIGTRI,0));
13806 12 item *bigtriforce = NULL;
13807 12 bigtriforce = (item *)items.spr(items.Count() - 1);
13808 12 bigtriforce->linked_parent = eeGANON;
13809 12 }
13810 24 }
13811 //setmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
13812 //game->lvlitems[dlevel]|=liBOSS; // if we had more rule bits, we could mark him dead so that he does not respawn. -Z
13813 12 }
13814
13815 960 break;
13816 10 case 5: return true;
13817 }
13818
13819 18244 return enemy::animate(index);
13820 18254 }
13821
13822
13823 964 int32_t eGanon::takehit(weapon *w, weapon* realweap)
13824 {
13825 //these are here to bypass compiler warnings about unused arguments
13826 964 int32_t wpnId = w->id;
13827 964 int32_t power = w->power;
13828 964 int32_t enemyHitWeapon = w->parentitem;
13829
13830
3/3
✓ Branch 0 taken 714 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 166 times.
964 switch(misc)
13831 {
13832 case 0:
13833
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 53 times.
84 if(wpnId!=wSword)
13834 31 return 0;
13835
13836 53 hp-=power;
13837
13838
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 12 times.
53 if(hp>0)
13839 {
13840 41 misc=1;
13841 41 Stunclk=64;
13842 41 }
13843 else
13844 {
13845 12 loadpalset(csBOSS,pSprite(spBROWN));
13846 12 misc=2;
13847 12 Stunclk=284;
13848 12 hp=guysbuf[id&0xFFF].hp; //16*game->get_hero_dmgmult();
13849 }
13850
13851 53 sfx(WAV_EHIT,pan(int32_t(x)));
13852
13853
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 if(hitsfx>0) sfx(hitsfx,pan(int32_t(x)));
13854
13855 53 return 1;
13856
13857 case 2:
13858
4/6
✓ Branch 0 taken 154 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 12 times.
166 if(wpnId!=wArrow || (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_arrow))<4)
13859 154 return 0;
13860
13861 12 misc=3;
13862 12 hclk=81;
13863 12 loadpalset(9,pSprite(spBROWN));
13864 12 return 1;
13865 }
13866
13867 714 return 0;
13868 964 }
13869
13870 20776 void eGanon::draw(BITMAP *dest)
13871 {
13872
6/6
✓ Branch 0 taken 3608 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 983 times.
✓ Branch 3 taken 2535 times.
✓ Branch 4 taken 12680 times.
✓ Branch 5 taken 960 times.
20776 switch(misc)
13873 {
13874 case 0:
13875
2/2
✓ Branch 0 taken 9511 times.
✓ Branch 1 taken 3169 times.
12680 if((clk&3)==3)
13876 3169 tile=(zc_oldrand()%5)*2+o_tile;
13877
13878
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12680 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12680 if ( (editorflags & ENEMY_FLAG1) && current_item_power(itype_amulet) >= 2 ) //ganon is visible to level 2 amulet
13879 {
13880
13881 if ( editorflags & ENEMY_FLAG16 ) //draw cloaked
13882 {
13883 int odraw = drawstyle;
13884 drawstyle = 2;
13885 drawblock(dest,15);
13886 drawstyle = odraw;
13887 }
13888 else
13889 {
13890 drawblock(dest,15);
13891 }
13892 break;
13893
13894 }
13895
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12680 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12680 else if ( (editorflags & ENEMY_FLAG2) && (game->item[dmisc13]) )
13896 {
13897 if ( editorflags & ENEMY_FLAG16 ) //draw cloaked
13898 {
13899 int odraw = drawstyle;
13900 drawstyle = 2;
13901 drawblock(dest,15);
13902 drawstyle = odraw;
13903 }
13904 else
13905 {
13906 drawblock(dest,15);
13907 }
13908 break;
13909 }
13910
1/2
✓ Branch 0 taken 12680 times.
✗ Branch 1 not taken.
12680 if(db!=999)
13911 12680 break;
13912 [[fallthrough]];
13913 case 2:
13914
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 983 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
983 if(Stunclk<64 && (Stunclk&1))
13915 break;
13916 [[fallthrough]];
13917 case -1:
13918 3518 tile=o_tile;
13919
13920 [[fallthrough]];
13921 case 1:
13922 case 3:
13923 7126 drawblock(dest,15);
13924 7126 break;
13925
13926 case 4:
13927 960 draw_guts(dest);
13928 960 draw_flash(dest);
13929 960 break;
13930 }
13931 20776 }
13932
13933 960 void eGanon::draw_guts(BITMAP *dest)
13934 {
13935
2/2
✓ Branch 0 taken 756 times.
✓ Branch 1 taken 204 times.
960 int32_t c = zc_min(clk>>3,8);
13936 960 tile = clk<24 ? 74 : 75;
13937 960 overtile16(dest,tile,x+8,y+c+playing_field_offset,9,0);
13938 960 overtile16(dest,tile,x+8,y+16-c+playing_field_offset,9,0);
13939 960 overtile16(dest,tile,x+c,y+8+playing_field_offset,9,0);
13940 960 overtile16(dest,tile,x+16-c,y+8+playing_field_offset,9,0);
13941 960 overtile16(dest,tile,x+c,y+c+playing_field_offset,9,0);
13942 960 overtile16(dest,tile,x+16-c,y+c+playing_field_offset,9,0);
13943 960 overtile16(dest,tile,x+c,y+16-c+playing_field_offset,9,0);
13944 960 overtile16(dest,tile,x+16-c,y+16-c+playing_field_offset,9,0);
13945 960 }
13946
13947 960 void eGanon::draw_flash(BITMAP *dest)
13948 {
13949
13950 960 int32_t c = clk-(clk>>2);
13951 960 cs = (frame&3)+6;
13952 960 overtile16(dest,194,x+8,y+8-clk+playing_field_offset,cs,0);
13953 960 overtile16(dest,194,x+8,y+8+clk+playing_field_offset,cs,2);
13954 960 overtile16(dest,195,x+8-clk,y+8+playing_field_offset,cs,0);
13955 960 overtile16(dest,195,x+8+clk,y+8+playing_field_offset,cs,1);
13956 960 overtile16(dest,196,x+8-c,y+8-c+playing_field_offset,cs,0);
13957 960 overtile16(dest,196,x+8+c,y+8-c+playing_field_offset,cs,1);
13958 960 overtile16(dest,196,x+8-c,y+8+c+playing_field_offset,cs,2);
13959 960 overtile16(dest,196,x+8+c,y+8+c+playing_field_offset,cs,3);
13960 960 }
13961
13962 15 void getBigTri(int32_t id2)
13963 {
13964 /*
13965 *************************
13966 * BIG TRIFORCE SEQUENCE *
13967 *************************
13968 0 BIGTRI out, WHITE flash in
13969 4 WHITE flash out, PILE cset white
13970 8 WHITE in
13971 ...
13972 188 WHITE out
13973 191 PILE cset red
13974 200 top SHUTTER opens
13975 209 bottom SHUTTER opens
13976 */
13977 15 sfx(itemsbuf[id2].playsound);
13978 15 guys.clear();
13979
13980
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
15 if(itemsbuf[id2].flags & item_gamedata)
13981 {
13982 game->lvlitems[dlevel]|=liTRIFORCE;
13983 }
13984
13985
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
15 setmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
13986
13987 15 draw_screen(tmpscr);
13988
13989
4/4
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 2880 times.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 2880 times.
2895 for(int32_t f=0; f<24*8 && !Quit; f++)
13990 {
13991
2/2
✓ Branch 0 taken 2865 times.
✓ Branch 1 taken 15 times.
2880 if(f==4)
13992 {
13993
2/2
✓ Branch 0 taken 225 times.
✓ Branch 1 taken 15 times.
240 for(int32_t i=1; i<16; i++)
13994 {
13995 225 RAMpal[CSET(9)+i]=_RGB(255,255,255);
13996 225 }
13997 15 }
13998
13999
2/2
✓ Branch 0 taken 2520 times.
✓ Branch 1 taken 360 times.
2880 if((f&7)==0)
14000 {
14001
2/2
✓ Branch 0 taken 1080 times.
✓ Branch 1 taken 360 times.
1440 for(int32_t cs=2; cs<5; cs++)
14002 {
14003
2/2
✓ Branch 0 taken 16200 times.
✓ Branch 1 taken 1080 times.
17280 for(int32_t i=1; i<16; i++)
14004 {
14005 16200 RAMpal[CSET(cs)+i]=_RGB(255,255,255);
14006 16200 }
14007 1080 }
14008
14009 360 refreshpal=true;
14010 360 }
14011
14012
2/2
✓ Branch 0 taken 2520 times.
✓ Branch 1 taken 360 times.
2880 if((f&7)==4)
14013 {
14014
1/2
✓ Branch 0 taken 360 times.
✗ Branch 1 not taken.
360 if(currscr<128) loadlvlpal(DMaps[currdmap].color);
14015 else loadlvlpal(0xB);
14016 360 }
14017
14018
2/2
✓ Branch 0 taken 2865 times.
✓ Branch 1 taken 15 times.
2880 if(f==191)
14019 {
14020 15 loadpalset(9,pSprite(spPILE));
14021 15 }
14022
14023 2880 advanceframe(true);
14024 2880 }
14025
14026 //play_DmapMusic();
14027 15 playLevelMusic();
14028
14029
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 13 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
15 if(itemsbuf[id2].flags & item_flag1 && currscr < 128)
14030 {
14031 2 Hero.dowarp(1,0); //side warp
14032 2 }
14033 15 }
14034
14035 //! No. I am not adding SIZEflags to Moldorm and Lanmola. -Z 12 Aug 2020
14036 618 eMoldorm::eMoldorm(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
14037 618 {
14038
1/2
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
618 if( !(editorflags & ENEMY_FLAG5) )
14039 {
14040
1/2
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
618 x=128;
14041
1/2
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
618 y=48;
14042 618 }
14043 //else { x = X; y = Y; }
14044
1/2
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
618 dir=(zc_oldrand()&7)+8;
14045 618 superman=1;
14046 618 fading=fade_invisible;
14047 618 hxofs=1000;
14048 618 segcnt=clk;
14049 618 segid=Id|0x1000;
14050 618 clk=0;
14051
1/2
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
618 id=guys.Count();
14052
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 618 times.
✓ Branch 2 taken 618 times.
✗ Branch 3 not taken.
618 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
14053 618 tile=o_tile;
14054 618 hitdir = -1;
14055 618 stickclk = 0;
14056
14057 /*
14058 if (get_qr(qr_NEWENEMYTILES))
14059 {
14060 tile=nets+1220;
14061 }
14062 else
14063 {
14064 tile=57;
14065 }
14066 */
14067 618 }
14068
14069 244844 bool eMoldorm::animate(int32_t index)
14070 {
14071
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 244844 times.
244844 if(switch_hooked) return enemy::animate(index);
14072 244844 int32_t max_y = isdungeon() ? 100 : 100+28; //warning: Ugly hack. -Z
14073
2/2
✓ Branch 0 taken 216369 times.
✓ Branch 1 taken 28475 times.
244844 if ( y > (max_y) )
14074 {
14075 28475 ++stickclk; //Keep Moldorm from pacinn the bottom row or leaving the screen via the bottom edge. -Z 8th Sept, 2019
14076 //Z_scripterrlog("Stickclk is %d\n", stickclk);
14077 28475 }
14078
2/2
✓ Branch 0 taken 244282 times.
✓ Branch 1 taken 562 times.
244844 if ( stickclk > 45 )
14079 {
14080 562 stickclk = 0;
14081 562 newdir_8_old(rate,homing,spw_floater); //chage dir to keep from getting stuck.
14082 562 }
14083
14084
14085
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 244844 times.
244844 if(clk==0)
14086 {
14087 244844 removearmos(x,y,ffcactivated);
14088 244844 }
14089
14090
2/2
✓ Branch 0 taken 2451 times.
✓ Branch 1 taken 242393 times.
244844 if(clk2)
14091 {
14092
2/2
✓ Branch 0 taken 2322 times.
✓ Branch 1 taken 129 times.
2451 if(--clk2 == 0)
14093 {
14094
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
129 if(flags&guy_never_return)
14095 129 never_return(index);
14096
14097
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
129 if(!dmisc2 || (editorflags & ENEMY_FLAG6))
14098 129 leave_item();
14099
14100 129 stop_bgsfx(index);
14101 129 return true;
14102 }
14103 2322 }
14104 else
14105 {
14106
1/2
✓ Branch 0 taken 242393 times.
✗ Branch 1 not taken.
242393 if(stunclk>0)
14107 stunclk=0;
14108 242393 constant_walk_8_old(rate,homing,spw_floater);
14109
14110
14111 242393 misc=dir;
14112
14113 // If any higher-numbered segments were killed, segcnt can be too high,
14114 // leading to a crash
14115
1/2
✓ Branch 0 taken 242393 times.
✗ Branch 1 not taken.
242393 if(index+segcnt>=guys.Count())
14116 segcnt=guys.Count()-index-1;
14117
14118
2/2
✓ Branch 0 taken 242393 times.
✓ Branch 1 taken 1122281 times.
1364674 for(int32_t i=index+1; i<index+segcnt+1; i++)
14119 {
14120 1122281 enemy* segment=((enemy*)guys.spr(i));
14121
14122 // More validation - if segcnt was wrong, this may not
14123 // actually be a Moldorm segment
14124
1/2
✓ Branch 0 taken 1122281 times.
✗ Branch 1 not taken.
1122281 if(segment->id!=segid)
14125 {
14126 segcnt=i-index-1;
14127 break;
14128 }
14129
14130
2/2
✓ Branch 0 taken 879612 times.
✓ Branch 1 taken 242669 times.
1122281 if(i==index+1)
14131 {
14132 242669 x=segment->x;
14133 242669 y=segment->y;
14134 242669 }
14135
14136 1122281 segment->o_tile=tile; //I refuse to fuck with adding scripttile to segmented enemies. -Z
14137 //Script your own blasted segmented bosses!! -Z
14138 1122281 segment->parent_script_UID = this->script_UID;
14139
4/4
✓ Branch 0 taken 242393 times.
✓ Branch 1 taken 879888 times.
✓ Branch 2 taken 24660 times.
✓ Branch 3 taken 217733 times.
1122281 if((i==index+segcnt)&&(i!=index+1)) //tail
14140 {
14141 217733 segment->dummy_int[1]=2;
14142 217733 }
14143 else
14144 {
14145 904548 segment->dummy_int[1]=1;
14146 }
14147
14148
2/2
✓ Branch 0 taken 879612 times.
✓ Branch 1 taken 242669 times.
1122281 if(i==index+1) //head
14149 {
14150 242669 segment->dummy_int[1]=0;
14151 242669 }
14152
14153
2/2
✓ Branch 0 taken 1121265 times.
✓ Branch 1 taken 1016 times.
1122281 if(segment->hp <= 0)
14154 {
14155 1016 int32_t offset=1;
14156
14157
2/2
✓ Branch 0 taken 1016 times.
✓ Branch 1 taken 1480 times.
2496 for(int32_t j=i; j<index+segcnt; j++)
14158 {
14159 // Triple-check
14160
1/2
✓ Branch 0 taken 1480 times.
✗ Branch 1 not taken.
1480 if(((enemy*)guys.spr(j+1))->id!=segid)
14161 {
14162 segcnt=j-index+1; // Add 1 because of --segcnt below
14163 break;
14164 }
14165 1480 zc_swap(((enemy*)guys.spr(j))->hp,((enemy*)guys.spr(j+1))->hp);
14166 1480 zc_swap(((enemy*)guys.spr(j))->hclk,((enemy*)guys.spr(j+1))->hclk);
14167 1480 }
14168
14169 1016 segment->hclk=33;
14170 1016 --segcnt;
14171 1016 --i; // Recheck the same index in case multiple segments died at once
14172 1016 }
14173 1122281 }
14174
14175
2/2
✓ Branch 0 taken 129 times.
✓ Branch 1 taken 242264 times.
242393 if(segcnt==0)
14176 {
14177 129 clk2=19;
14178
14179 129 x=guys.spr(index+1)->x;
14180 129 y=guys.spr(index+1)->y;
14181 129 }
14182 }
14183
14184 244715 return false;
14185 244844 }
14186
14187 3150 esMoldorm::esMoldorm(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
14188 3150 {
14189
1/2
✓ Branch 0 taken 3150 times.
✗ Branch 1 not taken.
3150 if( !(editorflags & ENEMY_FLAG5) )
14190 {
14191
1/2
✓ Branch 0 taken 3150 times.
✗ Branch 1 not taken.
3150 x=128;
14192
1/2
✓ Branch 0 taken 3150 times.
✗ Branch 1 not taken.
3150 y=48;
14193 3150 }
14194
14195
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3150 times.
✓ Branch 2 taken 3150 times.
✗ Branch 3 not taken.
3150 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
14196 3150 hyofs=4;
14197 3150 hit_width=hit_height=8;
14198 3150 hxofs=1000;
14199 3150 mainguy=count_enemy=false;
14200 3150 parentclk = 0;
14201 3150 bgsfx=-1;
14202
2/4
✓ Branch 0 taken 3150 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3150 times.
✗ Branch 3 not taken.
3150 flags&=~guy_never_return;
14203 //deadsfx = WAV_EDEAD;
14204 3150 isCore = false;
14205 3150 }
14206
14207 1138024 bool esMoldorm::animate(int32_t index)
14208 {
14209
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1138024 times.
1138024 if(switch_hooked) return enemy::animate(index);
14210 // Shouldn't be possible, but better to be sure
14211
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1138024 times.
1138024 if(index==0)
14212 dying=true;
14213
14214
2/2
✓ Branch 0 taken 15743 times.
✓ Branch 1 taken 1122281 times.
1138024 if(dying)
14215 {
14216
1/2
✓ Branch 0 taken 15743 times.
✗ Branch 1 not taken.
15743 if(!dmisc2)
14217 15743 item_set=0;
14218
14219 15743 return Dead(index);
14220 }
14221
14222
2/2
✓ Branch 0 taken 105077 times.
✓ Branch 1 taken 1017204 times.
1122281 if(clk>=0)
14223 {
14224 1017204 hxofs=4;
14225 1017204 step=((enemy*)guys.spr(index-1))->step;
14226
14227
2/2
✓ Branch 0 taken 70455 times.
✓ Branch 1 taken 946749 times.
1017204 if(parentclk == 0)
14228 {
14229 70455 misc=dir;
14230 70455 dir=((enemy*)guys.spr(index-1))->misc;
14231 //do alignment, as in parent's animation :-/ -DD
14232 70455 x.doFloor();
14233 70455 y.doFloor();
14234 70455 }
14235
14236
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1017204 times.
1017204 if(step)
14237 1017204 parentclk=(parentclk+1)%((int32_t)(8.0/step));
14238
14239
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1017204 times.
1017204 if(!watch)
14240 {
14241 1017204 sprite::move(step);
14242 1017204 }
14243 1017204 }
14244
14245 1122281 return enemy::animate(index);
14246 1138024 }
14247
14248 2683 int32_t esMoldorm::takehit(weapon *w, weapon* realweap)
14249 {
14250
2/2
✓ Branch 0 taken 2230 times.
✓ Branch 1 taken 453 times.
2683 if(enemy::takehit(w,realweap))
14251 2230 return (w->id==wSBomb) ? 1 : 2; // force it to wait a frame before checking sword attacks again
14252
14253 453 return 0;
14254 2683 }
14255
14256 1155313 void esMoldorm::draw(BITMAP *dest)
14257 {
14258 1155313 tile=o_tile;
14259 1155313 int32_t fdiv = frate/4;
14260
1/2
✓ Branch 0 taken 1155313 times.
✗ Branch 1 not taken.
1155313 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
14261
14262
2/2
✓ Branch 0 taken 1043930 times.
✓ Branch 1 taken 111383 times.
1155313 int32_t f2=get_qr(qr_NEWENEMYTILES)?
14263 1155313 efrate:((clk>=(frate>>1))?1:0);
14264
14265
2/2
✓ Branch 0 taken 111383 times.
✓ Branch 1 taken 1043930 times.
1155313 if(get_qr(qr_NEWENEMYTILES))
14266 {
14267 1043930 tile+=dummy_int[1]*40;
14268
14269
2/2
✓ Branch 0 taken 102730 times.
✓ Branch 1 taken 941200 times.
1043930 if(dir<8)
14270 {
14271 102730 flip=0;
14272
1/2
✓ Branch 0 taken 102730 times.
✗ Branch 1 not taken.
102730 tile+=4*zc_max(dir, 0); // dir is -1 if trapped
14273
14274
1/2
✓ Branch 0 taken 102730 times.
✗ Branch 1 not taken.
102730 if(dir>3) // Skip to the next row for diagonals
14275 tile+=4;
14276 102730 }
14277 else
14278 {
14279
8/9
✓ Branch 0 taken 96530 times.
✓ Branch 1 taken 134534 times.
✓ Branch 2 taken 113426 times.
✓ Branch 3 taken 124800 times.
✓ Branch 4 taken 101314 times.
✓ Branch 5 taken 99043 times.
✓ Branch 6 taken 131794 times.
✓ Branch 7 taken 139759 times.
✗ Branch 8 not taken.
941200 switch(dir-8) //directions get screwed up after 8. *shrug*
14280 {
14281 case up: //u
14282 96530 flip=0;
14283 96530 break;
14284
14285 case l_up: //d
14286 134534 flip=0;
14287 134534 tile+=4;
14288 134534 break;
14289
14290 case l_down: //l
14291 113426 flip=0;
14292 113426 tile+=8;
14293 113426 break;
14294
14295 case left: //r
14296 124800 flip=0;
14297 124800 tile+=12;
14298 124800 break;
14299
14300 case r_down: //ul
14301 101314 flip=0;
14302 101314 tile+=20;
14303 101314 break;
14304
14305 case down: //ur
14306 99043 flip=0;
14307 99043 tile+=24;
14308 99043 break;
14309
14310 case r_up: //dl
14311 131794 flip=0;
14312 131794 tile+=28;
14313 131794 break;
14314
14315 case right: //dr
14316 139759 flip=0;
14317 139759 tile+=32;
14318 139759 break;
14319 }
14320 }
14321
14322 1043930 tile+=f2;
14323 1043930 }
14324
14325
2/2
✓ Branch 0 taken 106267 times.
✓ Branch 1 taken 1049046 times.
1155313 if(clk>=0)
14326 1049046 enemy::draw(dest);
14327 1155313 }
14328
14329 420 eLanmola::eLanmola(zfix X,zfix Y,int32_t Id,int32_t Clk) : eBaseLanmola(X,Y,Id,Clk)
14330 420 {
14331
1/2
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
420 if( !(editorflags & ENEMY_FLAG5) )
14332 {
14333
1/2
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
420 x=64;
14334
1/2
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
420 y=80;
14335 420 }
14336 //else { x = X; y = Y; }
14337 //byte legaldirs = 0;
14338 420 int32_t incr = 16;
14339 //int32_t possiiblepos = 0;
14340 //int32_t positions[8] = {0};
14341
14342 //Don't spawn in pits.
14343
5/8
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 420 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 420 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 315 times.
✓ Branch 7 taken 105 times.
420 if ( m_walkflag_simple(x, y) )
14344 {
14345
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
139 for ( ; incr < 240; incr += 16 )
14346 {
14347 //move if we spawn over a pit
14348 //check each direction
14349
7/12
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 139 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 139 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 139 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 139 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 4 times.
✓ Branch 11 taken 135 times.
139 if ( !m_walkflag_simple(x-incr, y) ) //legaldirs |= 0x1; //left
14350 {
14351
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 x-=incr; break;
14352 }
14353
7/12
✓ Branch 0 taken 135 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 135 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 135 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 135 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 135 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 39 times.
✓ Branch 11 taken 96 times.
135 else if ( !m_walkflag_simple(x+incr, y) ) //legaldirs |= 0x2; //right
14354 {
14355
1/2
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
39 x+=incr; break;
14356 }
14357
9/16
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 96 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 96 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 96 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 96 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 96 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 32 times.
✓ Branch 15 taken 64 times.
96 else if ( !m_walkflag_simple(x-incr, y-incr) ) //legaldirs |= 0x4; //left-up
14358 {
14359
2/4
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 32 times.
✗ Branch 3 not taken.
32 x-=incr; y-=incr; break;
14360 }
14361
9/16
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 64 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 64 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 64 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 64 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 64 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 64 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 4 times.
✓ Branch 15 taken 60 times.
64 else if ( !m_walkflag_simple(x+incr, y-incr) ) //legaldirs |= 0x8; //right-up
14362 {
14363
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
4 x+=incr; y-=incr; break;
14364 }
14365
6/12
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 60 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 60 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 60 times.
60 else if ( !m_walkflag_simple(x, y-incr) ) // legaldirs |= 0x10; //up
14366 {
14367 y -= incr; break;
14368 }
14369
6/12
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 60 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 60 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 60 times.
60 else if ( !m_walkflag_simple(x, y+incr) ) //legaldirs |= 0x20; //down
14370 {
14371 y+=incr; break;
14372 }
14373
9/16
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 60 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 60 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 60 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 60 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 26 times.
✓ Branch 15 taken 34 times.
60 else if ( !m_walkflag_simple(x-incr, y+incr) ) //legaldirs |= 0x40; //left-down
14374 {
14375
2/4
✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26 times.
✗ Branch 3 not taken.
26 x-=incr; y+=incr; break;
14376 }
14377
8/16
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 34 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 34 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 34 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 34 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 34 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 34 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 34 times.
34 else if ( !m_walkflag_simple(x+incr, y+incr) ) //legaldirs |= 0x80; //right-down
14378 {
14379 x+=incr; y+=incr; break;
14380 }
14381 34 else continue;
14382
14383 }
14384
14385 105 }
14386
14387 420 dir=up;
14388 420 superman=1;
14389 420 fading=fade_invisible;
14390 420 hxofs=1000;
14391 420 segcnt=clk;
14392 420 clk=0;
14393 //set up move history
14394
2/2
✓ Branch 0 taken 420 times.
✓ Branch 1 taken 3060 times.
3480 for(int32_t i=0; i <= (1<<dmisc2); i++)
14395
3/6
✓ Branch 0 taken 3060 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3060 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3060 times.
✗ Branch 5 not taken.
3060 prevState.push_back(std::pair<std::pair<zfix, zfix>, int32_t>(std::pair<zfix,zfix>(x,y), dir));
14396 420 }
14397
14398 236907 bool eLanmola::animate(int32_t index)
14399 {
14400
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 236907 times.
236907 if(switch_hooked) return enemy::animate(index);
14401
2/2
✓ Branch 0 taken 196711 times.
✓ Branch 1 taken 40196 times.
236907 if(clk==0)
14402 {
14403 40196 removearmos(x,y,ffcactivated);
14404 40196 }
14405
14406
2/2
✓ Branch 0 taken 3591 times.
✓ Branch 1 taken 233316 times.
236907 if(clk2)
14407 {
14408
2/2
✓ Branch 0 taken 3402 times.
✓ Branch 1 taken 189 times.
3591 if(--clk2 == 0)
14409 {
14410
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 103 times.
189 if(!dmisc3) //This checks if "segments drop items" isn't true, because if they don't drop items, then only killing the whole thing drops an item.
14411 86 leave_item();
14412
14413 189 stop_bgsfx(index);
14414 189 return true;
14415 }
14416
14417 3402 return false;
14418 }
14419
14420
14421 //this animation style plays ALL KINDS of havoc on the Lanmola segments, since it causes
14422 //the direction AND x,y position of the lanmola to vary in uncertain ways.
14423 //I've added a complete movement history to this enemy to compensate -DD
14424 233316 constant_walk(rate,homing,spw_none);
14425 233316 prevState.pop_front();
14426 233316 prevState.push_front(std::pair<std::pair<zfix, zfix>, int32_t>(std::pair<zfix, zfix>(x,y), dir));
14427
14428 // This could cause a crash with Moldorms. I didn't see the same problem
14429 // with Lanmolas, but it looks like it ought to be possible, so here's
14430 // the same solution. - Saf
14431
1/2
✓ Branch 0 taken 233316 times.
✗ Branch 1 not taken.
233316 if(index+segcnt>=guys.Count())
14432 segcnt=guys.Count()-index-1;
14433
14434
2/2
✓ Branch 0 taken 233316 times.
✓ Branch 1 taken 966396 times.
1199712 for(int32_t i=index+1; i<index+segcnt+1; i++)
14435 {
14436 966396 enemy* segment=((enemy*)guys.spr(i));
14437
14438 // More validation in case segcnt is wrong
14439
1/2
✓ Branch 0 taken 966396 times.
✗ Branch 1 not taken.
966396 if((segment->id&0xFFF)!=(id&0xFFF))
14440 {
14441 segcnt=i-index-1;
14442 break;
14443 }
14444
14445 966396 segment->o_tile=o_tile;
14446 966396 segment->parent_script_UID = this->script_UID;
14447
4/4
✓ Branch 0 taken 233316 times.
✓ Branch 1 taken 733080 times.
✓ Branch 2 taken 37616 times.
✓ Branch 3 taken 195700 times.
966396 if((i==index+segcnt)&&(i!=index+1))
14448 {
14449 195700 segment->dummy_int[1]=1; //tail
14450 195700 }
14451 else
14452 {
14453 770696 segment->dummy_int[1]=0;
14454 }
14455
14456
2/2
✓ Branch 0 taken 965227 times.
✓ Branch 1 taken 1169 times.
966396 if(segment->hp <= 0)
14457 {
14458
2/2
✓ Branch 0 taken 1169 times.
✓ Branch 1 taken 1961 times.
3130 for(int32_t j=i; j<index+segcnt; j++)
14459 {
14460 // Triple-check
14461
1/2
✓ Branch 0 taken 1961 times.
✗ Branch 1 not taken.
1961 if((((enemy*)guys.spr(j+1))->id&0xFFF)!=(id&0xFFF))
14462 {
14463 segcnt=j-index+1; // Add 1 because of --segcnt below
14464 break;
14465 }
14466 1961 zc_swap(((enemy*)guys.spr(j))->hp,((enemy*)guys.spr(j+1))->hp);
14467 1961 zc_swap(((enemy*)guys.spr(j))->hclk,((enemy*)guys.spr(j+1))->hclk);
14468 1961 }
14469
14470 1169 ((enemy*)guys.spr(i))->hclk=33;
14471 1169 --segcnt;
14472 1169 --i; // Recheck the same index in case multiple segments died at once
14473 1169 }
14474 966396 }
14475
14476
2/2
✓ Branch 0 taken 233127 times.
✓ Branch 1 taken 189 times.
233316 if(segcnt==0)
14477 {
14478 189 clk2=19;
14479 189 x=guys.spr(index+1)->x;
14480 189 y=guys.spr(index+1)->y;
14481 189 setmapflag(mTMPNORET);
14482 189 }
14483
14484 //this enemy is invincible.. BUT scripts don't know that, and can "kill" it by setting the hp negative.
14485 //which is... disastrous.
14486 233316 hp = 1;
14487 233316 return enemy::animate(index);
14488 236907 }
14489
14490 2267 esLanmola::esLanmola(zfix X,zfix Y,int32_t Id,int32_t Clk) : eBaseLanmola(X,Y,Id,Clk)
14491 2267 {
14492
1/2
✓ Branch 0 taken 2267 times.
✗ Branch 1 not taken.
2267 if( !(editorflags & ENEMY_FLAG5) )
14493 {
14494
1/2
✓ Branch 0 taken 2267 times.
✗ Branch 1 not taken.
2267 x=64;
14495
1/2
✓ Branch 0 taken 2267 times.
✗ Branch 1 not taken.
2267 y=80;
14496 2267 }
14497 2267 int32_t incr = 16;
14498 //Don't spawn in pits.
14499
5/8
✓ Branch 0 taken 2267 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2267 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2267 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1742 times.
✓ Branch 7 taken 525 times.
2267 if ( m_walkflag_simple(x, y) )
14500 {
14501
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 695 times.
695 for ( ; incr < 240; incr += 16 )
14502 {
14503 //move if we spawn over a pit
14504 //check each direction
14505
7/12
✓ Branch 0 taken 695 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 695 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 695 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 695 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 695 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 20 times.
✓ Branch 11 taken 675 times.
695 if ( !m_walkflag_simple(x-incr, y) ) //legaldirs |= 0x1; //left
14506 {
14507
1/2
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
20 x-=incr; break;
14508 }
14509
7/12
✓ Branch 0 taken 675 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 675 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 675 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 675 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 675 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 195 times.
✓ Branch 11 taken 480 times.
675 else if ( !m_walkflag_simple(x+incr, y) ) //legaldirs |= 0x2; //right
14510 {
14511
1/2
✓ Branch 0 taken 195 times.
✗ Branch 1 not taken.
195 x+=incr; break;
14512 }
14513
9/16
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 480 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 480 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 480 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 480 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 480 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 480 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 160 times.
✓ Branch 15 taken 320 times.
480 else if ( !m_walkflag_simple(x-incr, y-incr) ) //legaldirs |= 0x4; //left-up
14514 {
14515
2/4
✓ Branch 0 taken 160 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 160 times.
✗ Branch 3 not taken.
160 x-=incr; y-=incr; break;
14516 }
14517
9/16
✓ Branch 0 taken 320 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 320 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 320 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 320 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 320 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 320 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 320 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 20 times.
✓ Branch 15 taken 300 times.
320 else if ( !m_walkflag_simple(x+incr, y-incr) ) //legaldirs |= 0x8; //right-up
14518 {
14519
2/4
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
20 x+=incr; y-=incr; break;
14520 }
14521
6/12
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 300 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 300 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 300 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 300 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 300 times.
300 else if ( !m_walkflag_simple(x, y-incr) ) // legaldirs |= 0x10; //up
14522 {
14523 y -= incr; break;
14524 }
14525
6/12
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 300 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 300 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 300 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 300 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 300 times.
300 else if ( !m_walkflag_simple(x, y+incr) ) //legaldirs |= 0x20; //down
14526 {
14527 y+=incr; break;
14528 }
14529
9/16
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 300 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 300 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 300 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 300 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 300 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 300 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 130 times.
✓ Branch 15 taken 170 times.
300 else if ( !m_walkflag_simple(x-incr, y+incr) ) //legaldirs |= 0x40; //left-down
14530 {
14531
2/4
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 130 times.
✗ Branch 3 not taken.
130 x-=incr; y+=incr; break;
14532 }
14533
8/16
✓ Branch 0 taken 170 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 170 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 170 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 170 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 170 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 170 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 170 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 170 times.
170 else if ( !m_walkflag_simple(x+incr, y+incr) ) //legaldirs |= 0x80; //right-down
14534 {
14535 x+=incr; y+=incr; break;
14536 }
14537 170 else continue;
14538
14539 }
14540
14541 525 }
14542
14543 2267 hxofs=1000;
14544 2267 hit_width=8;
14545 2267 mainguy=false;
14546 2267 count_enemy=(id<0x2000)?true:false;
14547
14548 //set up move history
14549
2/2
✓ Branch 0 taken 2267 times.
✓ Branch 1 taken 16763 times.
19030 for(int32_t i=0; i <= (1<<dmisc2); i++)
14550
3/6
✓ Branch 0 taken 16763 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16763 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16763 times.
✗ Branch 5 not taken.
16763 prevState.push_back(std::pair<std::pair<zfix, zfix>, int32_t>(std::pair<zfix,zfix>(x,y), dir));
14551
14552 2267 bgsfx = -1;
14553 2267 isCore = false;
14554
2/4
✓ Branch 0 taken 2267 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2267 times.
✗ Branch 3 not taken.
2267 flags&=~guy_never_return;
14555 2267 }
14556
14557 985563 bool esLanmola::animate(int32_t index)
14558 {
14559
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 985563 times.
985563 if(switch_hooked) return enemy::animate(index);
14560 // Shouldn't be possible, but who knows
14561
2/2
✓ Branch 0 taken 985545 times.
✓ Branch 1 taken 18 times.
985563 if(index==0)
14562 18 dying=true;
14563
14564
2/2
✓ Branch 0 taken 19167 times.
✓ Branch 1 taken 966396 times.
985563 if(dying)
14565 {
14566 19167 xofs=0;
14567
14568
2/2
✓ Branch 0 taken 9861 times.
✓ Branch 1 taken 9306 times.
19167 if(!dmisc3)
14569 9306 item_set=0;
14570
14571 19167 return Dead(index);
14572 }
14573
14574
2/2
✓ Branch 0 taken 35946 times.
✓ Branch 1 taken 930450 times.
966396 if(clk>=0)
14575 {
14576 930450 hxofs=4;
14577
14578
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 930450 times.
930450 if(!watch)
14579 {
14580 930450 std::pair<std::pair<zfix, zfix>, int32_t> newstate = ((eBaseLanmola*)guys.spr(index-1))->prevState.front();
14581 930450 prevState.pop_front();
14582 930450 prevState.push_back(newstate);
14583 930450 x = newstate.first.first;
14584 930450 y = newstate.first.second;
14585 930450 dir = newstate.second;
14586 930450 }
14587 930450 }
14588
14589 966396 return enemy::animate(index);
14590 985563 }
14591
14592 2655 int32_t esLanmola::takehit(weapon *w, weapon* realweap)
14593 {
14594
2/2
✓ Branch 0 taken 2065 times.
✓ Branch 1 taken 590 times.
2655 if(enemy::takehit(w,realweap))
14595 2065 return (w->id==wSBomb) ? 1 : 2; // force it to wait a frame before checking sword attacks again
14596
14597 590 return 0;
14598 2655 }
14599
14600 990931 void esLanmola::draw(BITMAP *dest)
14601 {
14602 990931 tile=o_tile;
14603 990931 int32_t fdiv = frate/4;
14604
1/2
✓ Branch 0 taken 990931 times.
✗ Branch 1 not taken.
990931 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
14605
14606
2/2
✓ Branch 0 taken 628932 times.
✓ Branch 1 taken 361999 times.
990931 int32_t f2=get_qr(qr_NEWENEMYTILES)?
14607 990931 efrate:((clk>=(frate>>1))?1:0);
14608
14609
2/2
✓ Branch 0 taken 628932 times.
✓ Branch 1 taken 361999 times.
990931 if(get_qr(qr_NEWENEMYTILES))
14610 {
14611
2/2
✓ Branch 0 taken 147165 times.
✓ Branch 1 taken 481767 times.
628932 if(id>=0x2000)
14612 {
14613 481767 tile+=20;
14614
14615
2/2
✓ Branch 0 taken 353025 times.
✓ Branch 1 taken 128742 times.
481767 if(dummy_int[1]==1)
14616 {
14617 128742 tile+=20;
14618 128742 }
14619 481767 }
14620
14621
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 141419 times.
✓ Branch 2 taken 140994 times.
✓ Branch 3 taken 159500 times.
✓ Branch 4 taken 187019 times.
628932 switch(dir)
14622 {
14623 case up:
14624 141419 flip=0;
14625 141419 break;
14626
14627 case down:
14628 140994 flip=0;
14629 140994 tile+=4;
14630 140994 break;
14631
14632 case left:
14633 159500 flip=0;
14634 159500 tile+=8;
14635 159500 break;
14636
14637 case right:
14638 187019 flip=0;
14639 187019 tile+=12;
14640 187019 break;
14641 }
14642
14643 628932 tile+=f2;
14644 628932 }
14645 else
14646 {
14647
2/2
✓ Branch 0 taken 90543 times.
✓ Branch 1 taken 271456 times.
361999 if(id>=0x2000)
14648 {
14649 271456 tile+=1;
14650 271456 }
14651 }
14652
14653
2/2
✓ Branch 0 taken 37038 times.
✓ Branch 1 taken 953893 times.
990931 if(clk>=0)
14654 953893 enemy::draw(dest);
14655 990931 }
14656
14657 150 eManhandla::eManhandla(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,0)
14658 150 {
14659 //these are here to bypass compiler warnings about unused arguments
14660 150 Clk=Clk;
14661 150 superman=1;
14662
1/2
✓ Branch 0 taken 150 times.
✗ Branch 1 not taken.
150 dir=(zc_oldrand()&7)+8;
14663 150 armcnt=dmisc2?8:4;//((id==eMANHAN)?4:8);
14664
14665
2/2
✓ Branch 0 taken 692 times.
✓ Branch 1 taken 150 times.
842 for(int32_t i=0; i<armcnt; i++)
14666 692 arm[i]=i;
14667
14668 150 fading=fade_blue_poof;
14669 //nets+4680;
14670 150 adjusted=false;
14671
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 150 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
150 if (SIZEflags != 0) init_size_flags();;
14672 150 }
14673
14674 66494 bool eManhandla::animate(int32_t index)
14675 {
14676
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66494 times.
66494 if(switch_hooked) return enemy::animate(index);
14677
2/2
✓ Branch 0 taken 1382 times.
✓ Branch 1 taken 65112 times.
66494 if(dying)
14678 1382 return Dead(index);
14679
14680
2/2
✓ Branch 0 taken 62641 times.
✓ Branch 1 taken 2471 times.
65112 if(clk==0)
14681 {
14682 2471 removearmos(x,y,ffcactivated);
14683 2471 }
14684
14685
14686 // check arm status, move dead ones to end of group
14687
2/2
✓ Branch 0 taken 193618 times.
✓ Branch 1 taken 65112 times.
258730 for(int32_t i=0; i<armcnt; i++)
14688 {
14689 193618 enemy* cur_arm = ((enemy*)guys.spr(index+i+1));
14690
3/4
✓ Branch 0 taken 193618 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 424 times.
✓ Branch 3 taken 193194 times.
193618 if(!cur_arm || cur_arm->dying)
14691 {
14692
2/2
✓ Branch 0 taken 552 times.
✓ Branch 1 taken 424 times.
976 for(int32_t j=i; j<armcnt-1; j++)
14693 {
14694 552 zc_swap(arm[j],arm[j+1]);
14695 552 guys.swap(index+j+1,index+j+2);
14696 552 }
14697
2/2
✓ Branch 0 taken 337 times.
✓ Branch 1 taken 87 times.
424 if((editorflags & ENEMY_FLAG6)) //They only did this in 2.10
14698 {
14699 87 leave_item();
14700 87 }
14701 424 --armcnt;
14702 424 --i;
14703 424 continue;
14704 }
14705
2/2
✓ Branch 0 taken 192502 times.
✓ Branch 1 taken 692 times.
193194 if(!adjusted)
14706 {
14707
2/2
✓ Branch 0 taken 508 times.
✓ Branch 1 taken 184 times.
692 if(!dmisc2)
14708 {
14709 508 cur_arm->o_tile=o_tile+40;
14710 508 cur_arm->parent_script_UID = this->script_UID;
14711 508 }
14712 else
14713 {
14714 184 cur_arm->o_tile=o_tile+160;
14715 184 cur_arm->parent_script_UID = this->script_UID;
14716 }
14717 692 }
14718 193194 }
14719
14720 65112 adjusted=true;
14721
14722 // move or die
14723
2/2
✓ Branch 0 taken 65029 times.
✓ Branch 1 taken 83 times.
65112 if(armcnt==0)
14724 83 hp=0;
14725 else
14726 {
14727 // Speed starts at 0.5, and increases by 0.5 for each head lost. Max speed is 4.5.
14728
2/2
✓ Branch 0 taken 53584 times.
✓ Branch 1 taken 11445 times.
65029 step = ((dmisc2 ? 8_zf : 4_zf) - armcnt) * 0.5 + (dstep / 100);
14729
1/2
✓ Branch 0 taken 65029 times.
✗ Branch 1 not taken.
65029 if (step > 4.5_zf) step = 4.5_zf;
14730 65029 int32_t dx1=0, dy1=-8, dx2=15, dy2=15;
14731
14732
2/2
✓ Branch 0 taken 53584 times.
✓ Branch 1 taken 11445 times.
65029 if(!dmisc2)
14733 {
14734
2/2
✓ Branch 0 taken 151019 times.
✓ Branch 1 taken 53584 times.
204603 for(int32_t i=0; i<armcnt; i++)
14735 {
14736
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 38579 times.
✓ Branch 2 taken 36328 times.
✓ Branch 3 taken 36250 times.
✓ Branch 4 taken 39862 times.
151019 switch(arm[i])
14737 {
14738 case 0:
14739 38579 dy1=-24;
14740 38579 break;
14741
14742 case 1:
14743 36328 dy2=31;
14744 36328 break;
14745
14746 case 2:
14747 36250 dx1=-16;
14748 36250 break;
14749
14750 case 3:
14751 39862 dx2=31;
14752 39862 break;
14753 }
14754 151019 }
14755 53584 }
14756 else
14757 {
14758 11445 dx1=-8, dy1=-16, dx2=23, dy2=23;
14759
14760
2/2
✓ Branch 0 taken 42175 times.
✓ Branch 1 taken 11445 times.
53620 for(int32_t i=0; i<armcnt; i++)
14761 {
14762
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 12012 times.
✓ Branch 2 taken 7730 times.
✓ Branch 3 taken 9837 times.
✓ Branch 4 taken 12596 times.
42175 switch(arm[i]&3)
14763 {
14764 case 0:
14765 12012 dy1=-32;
14766 12012 break;
14767
14768 case 1:
14769 7730 dy2=39;
14770 7730 break;
14771
14772 case 2:
14773 9837 dx1=-24;
14774 9837 break;
14775
14776 case 3:
14777 12596 dx2=39;
14778 12596 break;
14779 }
14780 42175 }
14781 }
14782
14783 65029 variable_walk_8(rate,homing,hrate,spw_floater,dx1,dy1,dx2,dy2);
14784
14785
2/2
✓ Branch 0 taken 193194 times.
✓ Branch 1 taken 65029 times.
258223 for(int32_t i=0; i<armcnt; i++)
14786 {
14787 193194 zfix dx=(zfix)0,dy=(zfix)0;
14788
14789
2/2
✓ Branch 0 taken 151019 times.
✓ Branch 1 taken 42175 times.
193194 if(!dmisc2)
14790 {
14791
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 38579 times.
✓ Branch 2 taken 36328 times.
✓ Branch 3 taken 36250 times.
✓ Branch 4 taken 39862 times.
151019 switch(arm[i])
14792 {
14793 case 0:
14794 38579 dy=-16;
14795 38579 break;
14796
14797 case 1:
14798 36328 dy=16;
14799 36328 break;
14800
14801 case 2:
14802 36250 dx=-16;
14803 36250 break;
14804
14805 case 3:
14806 39862 dx=16;
14807 39862 break;
14808 }
14809 151019 }
14810 else
14811 {
14812
8/9
✗ Branch 0 not taken.
✓ Branch 1 taken 5447 times.
✓ Branch 2 taken 3986 times.
✓ Branch 3 taken 4163 times.
✓ Branch 4 taken 6774 times.
✓ Branch 5 taken 6565 times.
✓ Branch 6 taken 3744 times.
✓ Branch 7 taken 5674 times.
✓ Branch 8 taken 5822 times.
42175 switch(arm[i])
14813 {
14814 case 0:
14815 5447 dy=-24;
14816 5447 dx=-8;
14817 5447 break;
14818
14819 case 1:
14820 3986 dy=24;
14821 3986 dx=8;
14822 3986 break;
14823
14824 case 2:
14825 4163 dx=-24;
14826 4163 dy=8;
14827 4163 break;
14828
14829 case 3:
14830 6774 dx=24;
14831 6774 dy=-8;
14832 6774 break;
14833
14834 case 4:
14835 6565 dy=-24;
14836 6565 dx=8;
14837 6565 break;
14838
14839 case 5:
14840 3744 dy=24;
14841 3744 dx=-8;
14842 3744 break;
14843
14844 case 6:
14845 5674 dx=-24;
14846 5674 dy=-8;
14847 5674 break;
14848
14849 case 7:
14850 5822 dx=24;
14851 5822 dy=8;
14852 5822 break;
14853 }
14854 }
14855
14856 193194 guys.spr(index+i+1)->x = x+dx;
14857 193194 guys.spr(index+i+1)->y = y+dy;
14858 193194 }
14859 }
14860
14861 65112 return enemy::animate(index);
14862 66494 }
14863
14864
14865 1751 int32_t eManhandla::takehit(weapon *w, weapon* realweap)
14866 {
14867 1751 int32_t wpnId = w->id;
14868
14869
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1751 times.
1751 if(dying)
14870 return 0;
14871
14872
3/4
✓ Branch 0 taken 923 times.
✓ Branch 1 taken 786 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 42 times.
1751 switch(wpnId)
14873 {
14874 case wBomb:
14875 case wSBomb:
14876 case wSword:
14877 case wHammer:
14878 case wWand:
14879
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 786 times.
786 if (get_qr(qr_MANHANDLA_BLOCK_SFX)) sfx(WAV_EHIT,pan(int32_t(x)));
14880
14881 case wLitBomb:
14882 case wLitSBomb:
14883 case wBait:
14884 case wWhistle:
14885 case wFire:
14886 case wWind:
14887 case wSSparkle:
14888 case wFSparkle:
14889 case wPhantom:
14890 1709 return 0;
14891
14892 case wHookshot:
14893 case wBrang:
14894 sfx(WAV_CHINK,pan(int32_t(x)));
14895 break;
14896
14897 default:
14898
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 if (get_qr(qr_MANHANDLA_BLOCK_SFX)) sfx(WAV_EHIT,pan(int32_t(x)));
14899 else sfx(WAV_CHINK,pan(int32_t(x)));
14900
14901 42 }
14902
14903 42 return 1;
14904 1751 }
14905
14906 66490 void eManhandla::draw(BITMAP *dest)
14907 {
14908 66490 tile=o_tile;
14909 66490 int32_t fdiv = frate/4;
14910
1/2
✓ Branch 0 taken 66490 times.
✗ Branch 1 not taken.
66490 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
14911
14912
2/2
✓ Branch 0 taken 48802 times.
✓ Branch 1 taken 17688 times.
66490 int32_t f2=get_qr(qr_NEWENEMYTILES)?
14913 66490 efrate:((clk>=(frate>>1))?1:0);
14914
14915
2/2
✓ Branch 0 taken 48802 times.
✓ Branch 1 taken 17688 times.
66490 if(get_qr(qr_NEWENEMYTILES))
14916 {
14917
2/2
✓ Branch 0 taken 11308 times.
✓ Branch 1 taken 37494 times.
48802 if(!dmisc2)
14918 {
14919
8/9
✓ Branch 0 taken 4771 times.
✓ Branch 1 taken 4640 times.
✓ Branch 2 taken 4995 times.
✓ Branch 3 taken 5574 times.
✓ Branch 4 taken 3793 times.
✓ Branch 5 taken 3930 times.
✓ Branch 6 taken 3908 times.
✓ Branch 7 taken 5883 times.
✗ Branch 8 not taken.
37494 switch(dir-8) //directions get screwed up after 8. *shrug*
14920 {
14921 case up: //u
14922 4771 flip=0;
14923 4771 break;
14924
14925 case l_up: //d
14926 4640 flip=0;
14927 4640 tile+=4;
14928 4640 break;
14929
14930 case l_down: //l
14931 4995 flip=0;
14932 4995 tile+=8;
14933 4995 break;
14934
14935 case left: //r
14936 5574 flip=0;
14937 5574 tile+=12;
14938 5574 break;
14939
14940 case r_down: //ul
14941 3793 flip=0;
14942 3793 tile+=20;
14943 3793 break;
14944
14945 case down: //ur
14946 3930 flip=0;
14947 3930 tile+=24;
14948 3930 break;
14949
14950 case r_up: //dl
14951 3908 flip=0;
14952 3908 tile+=28;
14953 3908 break;
14954
14955 case right: //dr
14956 5883 flip=0;
14957 5883 tile+=32;
14958 5883 break;
14959 }
14960
14961 37494 tile+=f2;
14962 37494 enemy::draw(dest);
14963 37494 } //manhandla 2, big body
14964 else
14965 {
14966
14967
8/9
✗ Branch 0 not taken.
✓ Branch 1 taken 1277 times.
✓ Branch 2 taken 1360 times.
✓ Branch 3 taken 2242 times.
✓ Branch 4 taken 1789 times.
✓ Branch 5 taken 1345 times.
✓ Branch 6 taken 805 times.
✓ Branch 7 taken 948 times.
✓ Branch 8 taken 1542 times.
11308 switch(dir-8) //directions get screwed up after 8. *shrug*
14968 {
14969 case up: //u
14970 1277 flip=0;
14971 1277 break;
14972
14973 case l_up: //d
14974 1360 flip=0;
14975 1360 tile+=8;
14976 1360 break;
14977
14978 case l_down: //l
14979 2242 flip=0;
14980 2242 tile+=40;
14981 2242 break;
14982
14983 case left: //r
14984 1789 flip=0;
14985 1789 tile+=48;
14986 1789 break;
14987
14988 case r_down: //ul
14989 1345 flip=0;
14990 1345 tile+=80;
14991 1345 break;
14992
14993 case down: //ur
14994 805 flip=0;
14995 805 tile+=88;
14996 805 break;
14997
14998 case r_up: //dl
14999 948 flip=0;
15000 948 tile+=120;
15001 948 break;
15002
15003 case right: //dr
15004 1542 flip=0;
15005 1542 tile+=128;
15006 1542 break;
15007 }
15008
15009 11308 tile+=(f2*2);
15010 11308 xofs-=8;
15011 11308 yofs-=8;
15012 11308 drawblock(dest,15);
15013 11308 xofs+=8;
15014 11308 yofs+=8;
15015 }
15016 48802 }
15017 else
15018 {
15019
2/2
✓ Branch 0 taken 515 times.
✓ Branch 1 taken 17173 times.
17688 if(!dmisc2)
15020 {
15021 17173 enemy::draw(dest);
15022 17173 }
15023 else
15024 {
15025 515 xofs-=8;
15026 515 yofs-=8;
15027 515 enemy::draw(dest);
15028 515 xofs+=16;
15029 515 enemy::draw(dest);
15030 515 yofs+=16;
15031 515 enemy::draw(dest);
15032 515 xofs-=16;
15033 515 enemy::draw(dest);
15034 515 xofs+=8;
15035 515 yofs-=8;
15036 }
15037 }
15038 66490 }
15039
15040 692 esManhandla::esManhandla(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
15041 692 {
15042 692 id=misc=clk;
15043 692 dir = clk & 3;
15044 692 clk=0;
15045 692 mainguy=count_enemy=false;
15046 692 dummy_bool[0]=false;
15047 692 item_set=0;
15048 692 bgsfx=-1;
15049 692 deadsfx = WAV_EDEAD;
15050
2/4
✓ Branch 0 taken 692 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 692 times.
✗ Branch 3 not taken.
692 flags &= (~guy_never_return);
15051 692 isCore = false;
15052
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 692 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
692 if (SIZEflags != 0) init_size_flags();;
15053 692 }
15054
15055 200202 bool esManhandla::animate(int32_t index)
15056 {
15057
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200202 times.
200202 if(switch_hooked) return enemy::animate(index);
15058
2/2
✓ Branch 0 taken 7008 times.
✓ Branch 1 taken 193194 times.
200202 if(dying)
15059 7008 return Dead(index);
15060
15061
2/2
✓ Branch 0 taken 12404 times.
✓ Branch 1 taken 180790 times.
193194 if(clk==0)
15062 {
15063 12404 removearmos(x,y,ffcactivated);
15064 12404 }
15065
15066
2/2
✓ Branch 0 taken 165298 times.
✓ Branch 1 taken 27896 times.
193194 if(--clk2<=0)
15067 {
15068 27896 clk2=unsigned(zc_oldrand())%5+5;
15069 27896 clk3^=1;
15070 27896 }
15071
15072
2/2
✓ Branch 0 taken 1491 times.
✓ Branch 1 taken 191703 times.
193194 if(!(zc_oldrand()&127))
15073 {
15074 1491 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
15075 1491 sfx(wpnsfx(wpn),pan(int32_t(x)));
15076 1491 }
15077
15078 193194 return enemy::animate(index);
15079 200202 }
15080
15081 200186 void esManhandla::draw(BITMAP *dest)
15082 {
15083 200186 tile=o_tile;
15084 200186 int32_t fdiv = frate/4;
15085
1/2
✓ Branch 0 taken 200186 times.
✗ Branch 1 not taken.
200186 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
15086
2/2
✓ Branch 0 taken 158716 times.
✓ Branch 1 taken 41470 times.
200186 int32_t f2=get_qr(qr_NEWENEMYTILES)?
15087 200186 efrate:((clk>=(frate>>1))?1:0);
15088
15089
2/2
✓ Branch 0 taken 158716 times.
✓ Branch 1 taken 41470 times.
200186 if(get_qr(qr_NEWENEMYTILES))
15090 {
15091
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 39945 times.
✓ Branch 2 taken 36845 times.
✓ Branch 3 taken 39966 times.
✓ Branch 4 taken 41960 times.
158716 switch(misc&3)
15092 {
15093 case up:
15094 39945 break;
15095
15096 case down:
15097 36845 tile+=4;
15098 36845 break;
15099
15100 case left:
15101 39966 tile+=8;
15102 39966 break;
15103
15104 case right:
15105 41960 tile+=12;
15106 41960 break;
15107 }
15108
15109 158716 tile+=f2;
15110 158716 }
15111 else
15112 {
15113
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 12394 times.
✓ Branch 2 taken 7883 times.
✓ Branch 3 taken 8961 times.
✓ Branch 4 taken 12232 times.
41470 switch(misc&3)
15114 {
15115 case down:
15116 8961 flip=2;
15117
15118 [[fallthrough]];
15119 case up:
15120 21355 tile=(clk3)?188:189;
15121 21355 break;
15122
15123 case right:
15124 12232 flip=1;
15125 [[fallthrough]];
15126
15127 case left:
15128 20115 tile=(clk3)?186:187;
15129 20115 break;
15130 }
15131 }
15132
15133 200186 enemy::draw(dest);
15134 200186 }
15135
15136 168 eGleeok::eGleeok(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk) //enemy((zfix)120,(zfix)48,Id,Clk)
15137 168 {
15138
1/2
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
168 if ( !(editorflags & ENEMY_FLAG5) )
15139 {
15140
1/2
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
168 x = 120;
15141
1/2
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
168 y = 48;
15142 168 }
15143 else
15144 {
15145 if ( !(editorflags & ENEMY_FLAG6) )
15146 {
15147 x = X; y = Y;
15148 }
15149 else
15150 {
15151 x = X+8; y = Y;
15152 }
15153 }
15154 168 hzsz = 32; // can't be jumped.
15155 168 flameclk=0;
15156 168 misc=clk; // total head count
15157 168 clk3=clk; // live head count
15158 168 clk=0;
15159 168 clk2=60; // fire ball clock
15160 // hp=(guysbuf[eGLEEOK2+(misc-2)].misc2)*(misc-1)*game->get_hero_dmgmult()+guysbuf[eGLEEOK2+(misc-2)].hp;
15161
1/2
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
168 hp=(guysbuf[id&0xFFF].attributes[1])*(misc-1)*game->get_hero_dmgmult()+guysbuf[id&0xFFF].hp;
15162 168 dir = down;
15163 168 hxofs=4;
15164 168 hit_width=8;
15165 // frate=17*4;
15166 168 fading=fade_blue_poof;
15167 //nets+5420;
15168
2/2
✓ Branch 0 taken 133 times.
✓ Branch 1 taken 35 times.
168 if(get_qr(qr_NEWENEMYTILES))
15169 {
15170 /*
15171 necktile=o_tile+8;
15172 if (dmisc3)
15173 {
15174 necktile+=8;
15175 }
15176 */
15177 133 necktile=o_tile+dmisc6;
15178 133 }
15179 else
15180 {
15181 35 necktile=s_tile;
15182 }
15183 168 }
15184
15185 155290 bool eGleeok::animate(int32_t index)
15186 {
15187
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 155290 times.
155290 if(switch_hooked) return enemy::animate(index);
15188
2/2
✓ Branch 0 taken 2199 times.
✓ Branch 1 taken 153091 times.
155290 if(dying)
15189 2199 return Dead(index);
15190
15191
2/2
✓ Branch 0 taken 152407 times.
✓ Branch 1 taken 684 times.
153091 if(clk==0)
15192 {
15193 684 removearmos(x,y,ffcactivated);
15194 684 }
15195
15196 // Check if a head was killed somehow...
15197
2/2
✓ Branch 0 taken 101719 times.
✓ Branch 1 taken 51372 times.
153091 if(index+1+clk3>=guys.Count())
15198 51372 clk3=guys.Count()-index-1;
15199
2/2
✓ Branch 0 taken 66050 times.
✓ Branch 1 taken 87041 times.
153091 if(index+1+misc>=guys.Count())
15200 87041 misc=guys.Count()-index-1;
15201
15202 //fix for the "kill all enemies" item
15203
2/2
✓ Branch 0 taken 153085 times.
✓ Branch 1 taken 6 times.
153091 if(hp==-1000)
15204 {
15205
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
18 for(int32_t i=0; i<clk3; ++i)
15206 {
15207 // I haven't seen this fail, but it seems like it ought to be
15208 // possible, so I'm checking for it. - Saf
15209
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if((((enemy*)guys.spr(index+i+1))->id&0xFFF)!=(id&0xFFF))
15210 break;
15211 12 ((enemy*)guys.spr(index+i+1))->hp=1; // re-animate each head,
15212 12 ((enemy*)guys.spr(index+i+1))->misc = -1; // disconnect it,
15213 12 ((enemy*)guys.spr(index+i+1))->animate(index+i+1); // let it animate one frame,
15214 12 ((enemy*)guys.spr(index+i+1))->hp=-1000; // and kill it for good
15215 12 }
15216
15217 6 clk3=0;
15218
15219
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
18 for(int32_t i=0; i<misc; i++)
15220 {
15221
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if((((enemy*)guys.spr(index+i+1))->id&0xFFF)!=(id&0xFFF))
15222 break;
15223 12 ((enemy*)guys.spr(index+i+1))->misc = -2; // give the signal to disappear
15224 12 }
15225 6 }
15226
15227
2/2
✓ Branch 0 taken 403171 times.
✓ Branch 1 taken 153091 times.
556262 for(int32_t i=0; i<clk3; i++)
15228 {
15229 403171 enemy *head = ((enemy*)guys.spr(index+i+1));
15230 403171 head->dummy_int[1]=necktile;
15231 403171 head->parent_script_UID = this->script_UID;
15232
15233
2/2
✓ Branch 0 taken 320127 times.
✓ Branch 1 taken 83044 times.
403171 if(get_qr(qr_NEWENEMYTILES))
15234 {
15235 320127 head->dummy_int[2]=o_tile+dmisc8; //connected head tile
15236 320127 head->dummy_int[3]=o_tile+dmisc9; //flying head tile
15237 320127 }
15238 else
15239 {
15240 83044 head->dummy_int[2]=necktile+1; //connected head tile
15241 83044 head->dummy_int[3]=necktile+2; //flying head tile
15242 }
15243
15244 403171 head->dmisc5=dmisc5; //neck segments
15245
15246 /*
15247 if (dmisc3)
15248 {
15249 head->dummy_bool[0]=true;
15250 }
15251 */
15252
2/2
✓ Branch 0 taken 397516 times.
✓ Branch 1 taken 5655 times.
403171 if(head->hclk)
15253 {
15254
2/2
✓ Branch 0 taken 4427 times.
✓ Branch 1 taken 1228 times.
5655 if(hclk==0)
15255 {
15256 1228 hp -= 1000 - head->hp;
15257 1228 hclk = 33;
15258
15259
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1228 times.
1228 if(hitsfx>0) sfx(hitsfx,pan(int32_t(head->x)));
15260
15261 1228 sfx(WAV_EHIT,pan(int32_t(head->x)));
15262 1228 }
15263
15264 5655 head->hclk = 0;
15265 5655 }
15266
15267 // Must be set in case of naughty ZScripts
15268 403171 head->hp = 1000;
15269 403171 }
15270
15271
2/2
✓ Branch 0 taken 152676 times.
✓ Branch 1 taken 415 times.
153091 if(hp<=(guysbuf[id&0xFFF].attributes[1]) * (clk3 - 1) * game->get_hero_dmgmult())
15272 {
15273 415 ((enemy*)guys.spr(index+clk3))->misc = -1; // give signal to fly off
15274 415 hp=(guysbuf[id&0xFFF].attributes[1])*(--clk3)*game->get_hero_dmgmult();
15275 415 }
15276
15277
2/2
✓ Branch 0 taken 57409 times.
✓ Branch 1 taken 95682 times.
153091 if(!dmisc3)
15278 {
15279
4/4
✓ Branch 0 taken 5291 times.
✓ Branch 1 taken 90391 times.
✓ Branch 2 taken 1287 times.
✓ Branch 3 taken 4004 times.
95682 if(++clk2>72 && !(zc_oldrand()&3))
15280 {
15281 1287 int32_t i=zc_oldrand()%misc;
15282 1287 enemy *head = ((enemy*)guys.spr(index+i+1));
15283 1287 addEwpn(head->x,head->y,head->z,wpn,3,wdp,dir,getUID(), 0, head->fakez);
15284 1287 sfx(wpnsfx(wpn),pan(int32_t(x)));
15285 1287 clk2=0;
15286 1287 }
15287 95682 }
15288 else
15289 {
15290
4/4
✓ Branch 0 taken 2357 times.
✓ Branch 1 taken 55052 times.
✓ Branch 2 taken 1800 times.
✓ Branch 3 taken 557 times.
57409 if(++clk2>100 && !(zc_oldrand()&3))
15291 {
15292 557 enemy *head = ((enemy*)guys.spr(zc_oldrand()%misc+index+1));
15293 557 head->timer=zc_oldrand()%50+50;
15294 557 clk2=0;
15295 557 }
15296 }
15297
15298
3/4
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 152964 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 127 times.
153091 if((hp<=0 && !immortal))
15299 {
15300
2/2
✓ Branch 0 taken 390 times.
✓ Branch 1 taken 127 times.
517 for(int32_t i=0; i<misc; i++)
15301 390 ((enemy*)guys.spr(index+i+1))->misc = -2; // give the signal to disappear
15302
15303
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 124 times.
127 if(flags&guy_never_return) never_return(index);
15304 127 }
15305
15306 153091 return enemy::animate(index);
15307 155290 }
15308
15309 1239 int32_t eGleeok::takehit(weapon*,weapon*)
15310 {
15311 1239 return 0;
15312 }
15313
15314 156918 void eGleeok::draw(BITMAP *dest)
15315 {
15316 156918 tile=o_tile;
15317
15318
2/2
✓ Branch 0 taken 2199 times.
✓ Branch 1 taken 154719 times.
156918 if(dying)
15319 {
15320 2199 enemy::draw(dest);
15321 2199 return;
15322 }
15323
15324 154719 int32_t f=clk/17;
15325
15326
2/2
✓ Branch 0 taken 120524 times.
✓ Branch 1 taken 34195 times.
154719 if(get_qr(qr_NEWENEMYTILES))
15327 {
15328 // body
15329 120524 xofs=-8;
15330 120524 yofs=32;
15331
15332
4/4
✓ Branch 0 taken 92588 times.
✓ Branch 1 taken 9155 times.
✓ Branch 2 taken 10095 times.
✓ Branch 3 taken 8686 times.
120524 switch(f)
15333
15334 {
15335 case 0:
15336 9155 tile+=0;
15337 9155 break;
15338
15339 case 1:
15340 10095 tile+=2;
15341 10095 break;
15342
15343 case 2:
15344 8686 tile+=4;
15345 8686 break;
15346
15347 default:
15348 92588 tile+=6;
15349 92588 break;
15350 }
15351 120524 }
15352 else
15353 {
15354 // body
15355 34195 xofs=-8;
15356 34195 yofs=32;
15357
15358
3/3
✓ Branch 0 taken 29222 times.
✓ Branch 1 taken 2514 times.
✓ Branch 2 taken 2459 times.
34195 switch(f)
15359 {
15360 case 0:
15361 2514 tile+=0;
15362 2514 break;
15363
15364 case 2:
15365 2459 tile+=4;
15366 2459 break;
15367
15368 default:
15369 29222 tile+=2;
15370 29222 break;
15371 }
15372 }
15373
15374 154719 enemy::drawblock(dest,15);
15375 156918 }
15376
15377 156918 void eGleeok::draw2(BITMAP *dest)
15378 {
15379 // the neck stub
15380 156918 tile=necktile;
15381 156918 xofs=0;
15382
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 156918 times.
156918 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
15383
15384
2/2
✓ Branch 0 taken 34737 times.
✓ Branch 1 taken 122181 times.
156918 if(get_qr(qr_NEWENEMYTILES))
15385 {
15386 122181 tile+=((clk&24)>>3);
15387 122181 }
15388
15389
3/4
✓ Branch 0 taken 154719 times.
✓ Branch 1 taken 2199 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 154719 times.
156918 if(hp > 0 && !dont_draw())
15390 {
15391
4/4
✓ Branch 0 taken 4731 times.
✓ Branch 1 taken 149988 times.
✓ Branch 2 taken 737 times.
✓ Branch 3 taken 3994 times.
154719 if((tmpscr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))
15392 737 sprite::drawcloaked(dest);
15393 else
15394 153982 sprite::draw(dest);
15395 154719 }
15396 156918 }
15397
15398
3/6
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 533 times.
✗ Branch 5 not taken.
1066 esGleeok::esGleeok(zfix X,zfix Y,int32_t Id,int32_t Clk, sprite * prnt) : enemy(X,Y,Id,Clk), parent(prnt)
15399 533 {
15400
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 xoffset=0;
15401
2/4
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
533 yoffset=(zfix)((dmisc5*4+2));
15402 // dummy_bool[0]=false;
15403 533 timer=0;
15404 /* fixing */
15405 533 hp=1000;
15406
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 step=1;
15407 533 item_set=0;
15408 //x=120; y=70;
15409
4/8
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 533 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 533 times.
✗ Branch 7 not taken.
533 x = xoffset+parent->x;
15410
4/8
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 533 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 533 times.
✗ Branch 7 not taken.
533 y = yoffset+parent->y;
15411 533 hxofs=4;
15412 533 hit_width=8;
15413
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 533 times.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
533 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
15414 533 clk2=clk; // how int32_t to wait before moving first time
15415 533 clk=0;
15416 533 mainguy=count_enemy=false;
15417
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 dir=zc_oldrand();
15418 533 clk3=((dir&2)>>1)+2; // left or right
15419 533 dir&=1; // up or down
15420
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 dmisc5=vbound(dmisc5,1,255);
15421 533 isCore = false;
15422
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 parentCore = parent->getUID();
15423
2/2
✓ Branch 0 taken 2132 times.
✓ Branch 1 taken 533 times.
2665 for(int32_t i=0; i<dmisc5; i++)
15424 {
15425 2132 nxoffset[i] = 0;
15426 2132 nyoffset[i] = 0;
15427
2/4
✓ Branch 0 taken 2132 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2132 times.
✗ Branch 3 not taken.
2132 nx[i] = ((((i*(int32_t)x) + (dmisc5-i)*((int32_t)parent->x))) /dmisc5);
15428
2/4
✓ Branch 0 taken 2132 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2132 times.
✗ Branch 3 not taken.
2132 ny[i] = ((((i*(int32_t)y) + (dmisc5-i)*((int32_t)parent->y))) /dmisc5);
15429 2132 }
15430
15431 533 necktile=0;
15432 //TODO compatibility? -DD
15433 /*
15434 for(int32_t i=0; i<4; i++)
15435 {
15436 nx[i]=124;
15437 ny[i]=i*6+48;
15438 }*/
15439 533 bgsfx=-1;
15440 //no need for deadsfx
15441 533 }
15442
15443 515535 bool esGleeok::animate(int32_t index)
15444 {
15445
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 515535 times.
515535 if(switch_hooked) return enemy::animate(index);
15446 // don't call removearmos() - it's a segment.
15447
15448 515535 dmisc5=vbound(dmisc5,1,255);
15449
15450
2/2
✓ Branch 0 taken 112773 times.
✓ Branch 1 taken 402762 times.
515535 if(misc == 0)
15451 {
15452 402762 x = (xoffset+parent->x);
15453 402762 y = (yoffset+parent->y);
15454
15455
2/2
✓ Branch 0 taken 1611048 times.
✓ Branch 1 taken 402762 times.
2013810 for(int32_t i=0; i<dmisc5; i++)
15456 {
15457 1611048 nx[i] = ((((i*(int32_t)x) + (dmisc5-i)*((int32_t)parent->x))) /dmisc5) + 3 + nxoffset[i];
15458 1611048 ny[i] = ((((i*(int32_t)y) + (dmisc5-i)*((int32_t)parent->y))) /dmisc5) + nyoffset[i];
15459 1611048 }
15460 402762 }
15461
15462 // set up the head tiles
15463 // headtile=nets+5588; //5580, actually. must adjust for direction later on
15464 /*
15465 if (dummy_bool[0]) //if this is a flame gleeok
15466 {
15467 headtile+=180;
15468 }
15469 */
15470 515535 headtile=dummy_int[2]; //5580, actually. must adjust for direction later on
15471 515535 flyingheadtile=dummy_int[3];
15472
15473 // set up the neck tiles
15474 515535 necktile=dummy_int[1];
15475
15476
2/2
✓ Branch 0 taken 112702 times.
✓ Branch 1 taken 402833 times.
515535 if(get_qr(qr_NEWENEMYTILES))
15477 {
15478 402833 necktile+=((clk&24)>>3);
15479 402833 }
15480
15481 /*
15482 else
15483 {
15484 necktile=145;
15485 }
15486 */
15487 // ?((dummy_bool[0])?(nets+4052+(16+((clk&24)>>3))):(nets+4040+(8+((clk&24)>>3)))):145)
15488
15489
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 402762 times.
✓ Branch 2 taken 112071 times.
✓ Branch 3 taken 300 times.
✓ Branch 4 taken 402 times.
515535 switch(misc)
15490 {
15491 case 0: // live head
15492 // set up the attached head tiles
15493 402762 tile=headtile;
15494
15495
2/2
✓ Branch 0 taken 82942 times.
✓ Branch 1 taken 319820 times.
402762 if(get_qr(qr_NEWENEMYTILES))
15496 {
15497 319820 tile+=((clk&24)>>3);
15498 /*
15499 if (dummy_bool[0]) {
15500 tile+=1561;
15501 }
15502 */
15503 319820 }
15504
15505 /*
15506 else
15507 {
15508 tile=146;
15509 }
15510 */
15511
4/4
✓ Branch 0 taken 104448 times.
✓ Branch 1 taken 298314 times.
✓ Branch 2 taken 11616 times.
✓ Branch 3 taken 92832 times.
402762 if(++clk2>=0 && !(clk2&3))
15512 {
15513
2/2
✓ Branch 0 taken 90773 times.
✓ Branch 1 taken 2059 times.
92832 if(y<= (int32_t)parent->y + 8) dir=down;
15514
15515
2/2
✓ Branch 0 taken 90911 times.
✓ Branch 1 taken 1921 times.
92832 if(y>= (int32_t)parent->y + dmisc5*8) dir = up;
15516
15517
4/4
✓ Branch 0 taken 9757 times.
✓ Branch 1 taken 83075 times.
✓ Branch 2 taken 9465 times.
✓ Branch 3 taken 292 times.
92832 if(y<= (int32_t)parent->y + 10 && !(zc_oldrand()&31))
15518 {
15519 292 dir^=1;
15520 292 }
15521
15522 92832 zfix tempx = x;
15523 92832 zfix tempy = y;
15524
15525 92832 sprite::move(step);
15526 92832 xoffset += (x-tempx);
15527 92832 yoffset += (y-tempy);
15528
15529
2/2
✓ Branch 0 taken 3863 times.
✓ Branch 1 taken 88969 times.
92832 if(clk2>=4)
15530 {
15531 3863 clk3^=1;
15532 3863 clk2=-4;
15533 3863 }
15534 else
15535 {
15536
2/2
✓ Branch 0 taken 87991 times.
✓ Branch 1 taken 978 times.
88969 if(x <= (int32_t)parent->x-(dmisc5*6))
15537 {
15538 978 clk3=right;
15539 978 }
15540
15541
2/2
✓ Branch 0 taken 88008 times.
✓ Branch 1 taken 961 times.
88969 if(x >= (int32_t)parent->x+(dmisc5*6))
15542 {
15543 961 clk3=left;
15544 961 }
15545
15546
4/4
✓ Branch 0 taken 60029 times.
✓ Branch 1 taken 28940 times.
✓ Branch 2 taken 56316 times.
✓ Branch 3 taken 3713 times.
88969 if(y <= (int32_t)parent->y+(dmisc5*6) && !(zc_oldrand()&15))
15547 {
15548 3713 clk3^=1; // x jig
15549 3713 }
15550 else
15551 {
15552
4/4
✓ Branch 0 taken 29223 times.
✓ Branch 1 taken 56033 times.
✓ Branch 2 taken 28372 times.
✓ Branch 3 taken 851 times.
85256 if(y<=(int32_t)parent->y+(dmisc5*4) && !(zc_oldrand()&31))
15553 {
15554 851 clk3^=1; // x switch back
15555 851 }
15556
15557 85256 clk2=-4;
15558 }
15559 }
15560
15561 92832 zc_swap(dir,clk3);
15562 92832 tempx = x;
15563 92832 tempy = y;
15564 92832 sprite::move(step);
15565 92832 xoffset += (x-tempx);
15566 92832 yoffset += (y-tempy);
15567 92832 zc_swap(dir,clk3);
15568
15569
2/2
✓ Branch 0 taken 278496 times.
✓ Branch 1 taken 92832 times.
371328 for(int32_t i=1; i<dmisc5; i++)
15570 {
15571 278496 nxoffset[i] = (zc_oldrand()%3);
15572 278496 nyoffset[i] = (zc_oldrand()%3);
15573 278496 }
15574 92832 }
15575
15576 402762 break;
15577
15578 case 1: // flying head
15579
2/2
✓ Branch 0 taken 6589 times.
✓ Branch 1 taken 105482 times.
112071 if(clk>=0)
15580
15581 {
15582 105482 variable_walk_8(rate,homing,hrate,spw_floater);
15583 105482 }
15584
15585 112071 break;
15586
15587 // the following are messages sent from the main guy...
15588 case -1: // got chopped off
15589 {
15590 300 misc=1;
15591 300 superman=1;
15592 300 hxofs=xofs=0;
15593 300 hit_width=16;
15594 300 cs=8;
15595 300 clk=-24;
15596 300 clk2=40;
15597 300 dir=(zc_oldrand()&7)+8;
15598 300 step=8.0/9.0;
15599 }
15600 300 break;
15601
15602 case -2: // the big guy is dead
15603 402 return true;
15604 }
15605
15606
2/2
✓ Branch 0 taken 475008 times.
✓ Branch 1 taken 40125 times.
515133 if(timer)
15607 {
15608
2/2
✓ Branch 0 taken 35334 times.
✓ Branch 1 taken 4791 times.
40125 if(!(timer%8))
15609 {
15610 4791 FireBreath(true);
15611 4791 }
15612
15613 40125 --timer;
15614 40125 }
15615
15616 515133 return enemy::animate(index);
15617 515535 }
15618
15619 7080 int32_t esGleeok::takehit(weapon *w, weapon* realweap)
15620 {
15621
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7080 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7080 if ((editorflags & ENEMY_FLAG7) && misc == 1)
15622 {
15623 int32_t wpnId = w->id;
15624
15625 if(dying)
15626 return 0;
15627
15628 switch(wpnId)
15629 {
15630 case wLitBomb:
15631 case wLitSBomb:
15632 case wBait:
15633 case wWhistle:
15634 case wFire:
15635 case wWind:
15636 case wSSparkle:
15637 case wFSparkle:
15638 case wPhantom:
15639 return 0;
15640
15641 case wHookshot:
15642 case wBrang:
15643 case wBeam:
15644 case wArrow:
15645 case wMagic:
15646 case wBomb:
15647 case wSBomb:
15648 sfx(WAV_CHINK,pan(int32_t(x)));
15649 break;
15650 default:
15651 break;
15652 }
15653
15654 return 1;
15655 }
15656 else
15657 {
15658 7080 int32_t ret = enemy::takehit(w,realweap);
15659
15660
2/2
✓ Branch 0 taken 1425 times.
✓ Branch 1 taken 5655 times.
7080 if(ret==-1)
15661 5655 return 2; // force it to wait a frame before checking sword attacks again
15662
15663 1425 return ret;
15664 }
15665 7080 }
15666
15667 521456 void esGleeok::draw(BITMAP *dest)
15668 {
15669 521456 dmisc5=vbound(dmisc5,1,255);
15670
15671
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 409106 times.
✓ Branch 2 taken 112350 times.
521456 switch(misc)
15672 {
15673 case 0: //neck
15674
1/2
✓ Branch 0 taken 409106 times.
✗ Branch 1 not taken.
409106 if(!dont_draw())
15675 {
15676
2/2
✓ Branch 0 taken 1227318 times.
✓ Branch 1 taken 409106 times.
1636424 for(int32_t i=1; i<dmisc5; i++) //draw the neck
15677 {
15678
2/2
✓ Branch 0 taken 978198 times.
✓ Branch 1 taken 249120 times.
1227318 if(get_qr(qr_NEWENEMYTILES))
15679 {
15680
4/4
✓ Branch 0 taken 23100 times.
✓ Branch 1 taken 955098 times.
✓ Branch 2 taken 20889 times.
✓ Branch 3 taken 2211 times.
978198 if((tmpscr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))
15681 2211 overtilecloaked16(dest,necktile+(i*dmisc7),nx[i]-4,ny[i]+playing_field_offset,0);
15682 else
15683 975987 overtile16(dest,necktile+(i*dmisc7),nx[i]-4,ny[i]+playing_field_offset,cs,0);
15684 978198 }
15685 else
15686 {
15687
3/4
✓ Branch 0 taken 4278 times.
✓ Branch 1 taken 244842 times.
✓ Branch 2 taken 4278 times.
✗ Branch 3 not taken.
249120 if((tmpscr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))
15688 overtilecloaked16(dest,necktile,nx[i]-4,ny[i]+playing_field_offset,0);
15689 else
15690 249120 overtile16(dest,necktile,nx[i]-4,ny[i]+playing_field_offset,cs,0);
15691 }
15692 1227318 }
15693 409106 }
15694
15695 409106 break;
15696
15697 case 1: //flying head
15698 112350 tile=flyingheadtile;
15699
15700
2/2
✓ Branch 0 taken 82692 times.
✓ Branch 1 taken 29658 times.
112350 if(get_qr(qr_NEWENEMYTILES))
15701 {
15702 82692 tile+=((clk&24)>>3);
15703 82692 break;
15704 }
15705
15706 /*
15707 else
15708 {
15709 tile=(clk&1)?147:148;
15710 break;
15711 }
15712 */
15713 29658 }
15714 521456 }
15715
15716 521456 void esGleeok::draw2(BITMAP *dest)
15717 {
15718 521456 enemy::draw(dest);
15719 521456 }
15720
15721 190 ePatra::ePatra(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)// enemy((zfix)128,(zfix)48,Id,Clk)
15722 190 {
15723
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if ( !(editorflags & ENEMY_FLAG5) )
15724 {
15725
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 x = 128;
15726
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 y = 48;
15727 190 }
15728 else { x = X; y = Y; }
15729 190 adjusted=false;
15730
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 dir=(zc_oldrand()&7)+8;
15731 //step=0.25;
15732 190 flycnt=dmisc1;
15733 190 flycnt2=dmisc2;
15734 190 loopcnt=0;
15735 190 clk4 = 0;
15736 190 clk5 = 0;
15737 190 clk6 = 0;
15738 190 clk7 = 0;
15739
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if(dmisc6<int16_t(1))dmisc6=1; // ratio cannot be 0!
15740
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if (dmisc29 == 0)
15741 {
15742
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 105 times.
190 if(!dmisc4)
15743 {
15744
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if (dmisc10) dmisc29 = (90 / 3);
15745 105 else dmisc29 = (84 / 3);
15746 105 }
15747 else
15748 {
15749
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
85 if (dmisc10) dmisc29 = (90 / 2);
15750 85 else dmisc29 = (84 / 2);
15751 }
15752 190 }
15753
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if (dmisc30 == 0)
15754 {
15755
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 105 times.
190 if(!dmisc4)
15756 {
15757
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if (dmisc10) dmisc30 = (90 / 3)*0.5;
15758 105 else dmisc30 = (84 / 3)*0.5;
15759 105 }
15760 else
15761 {
15762
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
85 if (dmisc10) dmisc30 = (90 / 2)*0.5;
15763 85 else dmisc30 = (84 / 2)*0.5;
15764 }
15765 190 }
15766
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if (dmisc31 == 0)
15767 {
15768
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 105 times.
190 if(!dmisc4)
15769 {
15770
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if (dmisc10) dmisc31 = (90 / 3)*2;
15771 105 else dmisc31 = (84 / 3)*2;
15772 105 }
15773 else
15774 {
15775
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
85 if (dmisc10) dmisc31 = (90 / 2)*0.5;
15776 85 else dmisc31 = (84 / 2)*0.5;
15777 }
15778 190 }
15779
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if (dmisc32 == 0)
15780 {
15781
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 105 times.
190 if(!dmisc4)
15782 {
15783
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if (dmisc10) dmisc32 = (90 / 3);
15784 105 else dmisc32 = (84 / 3);
15785 105 }
15786 else
15787 {
15788
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
85 if (dmisc10) dmisc32 = (90 / 2)*0.25;
15789 85 else dmisc32 = (84 / 2)*0.25;
15790 }
15791 190 }
15792
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 init_size_flags();
15793 190 }
15794
15795 161885 bool ePatra::animate(int32_t index)
15796 {
15797
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 161885 times.
161885 if(switch_hooked) return enemy::animate(index);
15798
2/2
✓ Branch 0 taken 1444 times.
✓ Branch 1 taken 160441 times.
161885 if(dying)
15799 {
15800
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 1444 times.
1516 for(int32_t i=index+1; i<index+flycnt+flycnt2+1; i++)
15801 {
15802 72 ((enemy*)guys.spr(i))->hp = -1000;
15803 72 }
15804
15805 1444 return Dead(index);
15806 }
15807
15808 160441 double basesize = 84;
15809
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (dmisc10) basesize = 90;
15810 160441 double halfsize = basesize / 2;
15811 160441 double quartersize = halfsize / 2;
15812 160441 double twothirdsize = (basesize / 3)*2;
15813 160441 double onethirdsize = (basesize / 3);
15814
15815
15816
2/2
✓ Branch 0 taken 123507 times.
✓ Branch 1 taken 36934 times.
160441 if(clk==0)
15817 {
15818 36934 removearmos(x,y,ffcactivated);
15819 36934 }
15820
15821
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 160441 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 160441 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
160441 if ((clk4 <=0 || clk4%2) && (clk7 <= 0 || clk6 <= -16))
15822 {
15823
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 160441 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
160441 if (!dmisc22 || loopcnt == 0 || (dmisc22 == 1 && loopcnt < 0)) variable_walk_8(rate,homing,hrate,spw_floater);
15824
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (loopcnt < 0) ++clk2;
15825
2/2
✓ Branch 0 taken 158644 times.
✓ Branch 1 taken 1797 times.
160441 if(++clk2>basesize)
15826 {
15827 1797 clk2=0;
15828
2/12
✗ Branch 0 not taken.
✓ Branch 1 taken 1797 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1797 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
1797 if ((!dmisc26 || (dmisc26 == 1 && flycnt) || (dmisc26 == 2 && !flycnt)) && (!(editorflags & ENEMY_FLAG10) || flycnt || flycnt2))
15829 {
15830
2/2
✓ Branch 0 taken 932 times.
✓ Branch 1 taken 865 times.
1797 if(loopcnt > 0)
15831 932 --loopcnt;
15832
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865 times.
865 else if (loopcnt == 0)
15833 {
15834
2/2
✓ Branch 0 taken 509 times.
✓ Branch 1 taken 356 times.
865 if((misc%dmisc6)==0)
15835 {
15836
1/2
✓ Branch 0 taken 356 times.
✗ Branch 1 not taken.
356 if (dmisc21 > 0) loopcnt=-dmisc21;
15837 356 else loopcnt=dmisc7;
15838 356 }
15839 865 }
15840 else if (loopcnt == -1) loopcnt=dmisc7;
15841 else ++loopcnt;
15842
15843
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1797 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1797 if (!(editorflags & ENEMY_FLAG9) || loopcnt == 0) ++misc;
15844 1797 }
15845 else
15846 {
15847 loopcnt = 0;
15848 misc = 1;
15849 }
15850 1797 }
15851 160441 }
15852
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (clk4 > 0) --clk4;
15853
15854
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (clk6 < 0)
15855 {
15856 if (dmisc5 == 1 || dmisc5 == 3)
15857 {
15858 if (get_qr(qr_NEWENEMYTILES))
15859 {
15860 if (clk7 <= 0 || clk6 != -16) ++clk6;
15861 if (clk6 == 0) o_tile=d->e_tile;
15862 else
15863 {
15864 if (clk6 >= -16) o_tile=d->e_tile + (IsBigAnim() ? 320 : 80);
15865 else o_tile=d->e_tile + (IsBigAnim() ? 160 : 40);
15866 }
15867 }
15868 else clk6 = 0;
15869 }
15870 }
15871
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 else if (dmisc19) ++clk6;
15872
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (clk5 < 0) ++clk5;
15873
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 else if (dmisc19) ++clk5;
15874
15875
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 160441 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
160441 if (clk7 > 0 && clk6 >= -16) --clk7;
15876
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (clk6 > 0) clk7 = 0;
15877
15878
2/2
✓ Branch 0 taken 660384 times.
✓ Branch 1 taken 160441 times.
820825 for(int32_t i=index+1; i<index+flycnt+1; i++)
15879 {
15880 //outside ring
15881
2/2
✓ Branch 0 taken 659040 times.
✓ Branch 1 taken 1344 times.
660384 if(!adjusted)
15882 {
15883
2/2
✓ Branch 0 taken 1152 times.
✓ Branch 1 taken 192 times.
1344 if(get_qr(qr_NEWENEMYTILES))
15884 {
15885 1152 ((enemy*)guys.spr(i))->o_tile=d->e_tile+dmisc8;
15886 1152 enemy *s = ((enemy*)guys.spr(i));
15887 1152 s->parent_script_UID = this->script_UID;
15888 1152 }
15889 else
15890 {
15891 192 ((enemy*)guys.spr(i))->o_tile=o_tile+1;
15892 192 enemy *s = ((enemy*)guys.spr(i));
15893 192 s->parent_script_UID = this->script_UID;
15894 }
15895
15896 1344 ((enemy*)guys.spr(i))->cs=dmisc9;
15897 1344 ((enemy*)guys.spr(i))->hp=dmisc3;
15898 1344 }
15899
15900
2/2
✓ Branch 0 taken 764 times.
✓ Branch 1 taken 659620 times.
660384 if(((enemy*)guys.spr(i))->hp <= 0)
15901 {
15902
2/2
✓ Branch 0 taken 2889 times.
✓ Branch 1 taken 764 times.
3653 for(int32_t j=i; j<index+flycnt+flycnt2; j++)
15903 {
15904 2889 guys.swap(j,j+1);
15905 2889 }
15906
15907
3/4
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 670 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 94 times.
764 if (--flycnt == 0 && dmisc23 != 0) step += zslongToFix(dmisc23*100);
15908 764 }
15909 else
15910 {
15911 659620 int32_t pos2 = ((enemy*)guys.spr(i))->misc;
15912
1/2
✓ Branch 0 taken 659620 times.
✗ Branch 1 not taken.
659620 double a2 = (clk2-pos2*(double)basesize/(dmisc1 == 0 ? 1 : dmisc1))*PI/halfsize;
15913
15914
2/2
✓ Branch 0 taken 212037 times.
✓ Branch 1 taken 447583 times.
659620 if(!dmisc4) //Big Ring
15915 {
15916 //maybe playing_field_offset here?
15917
2/2
✓ Branch 0 taken 237330 times.
✓ Branch 1 taken 210253 times.
447583 if(loopcnt>0)
15918 {
15919
1/2
✓ Branch 0 taken 237330 times.
✗ Branch 1 not taken.
237330 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc31) - zc::math::Sin(pos2*PI*2/(dmisc1 == 0 ? 1 : dmisc1))*((int64_t)abs(dmisc31)-abs(dmisc29));
15920
1/2
✓ Branch 0 taken 237330 times.
✗ Branch 1 not taken.
237330 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc31) + zc::math::Cos(pos2*PI*2/(dmisc1 == 0 ? 1 : dmisc1))*((int64_t)abs(dmisc31)-abs(dmisc29));
15921 237330 }
15922 else
15923 {
15924 210253 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc29);
15925 210253 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc29);
15926 }
15927
15928 447583 temp_x=guys.spr(i)->x;
15929 447583 temp_y=guys.spr(i)->y;
15930 447583 }
15931 else //Oval
15932 {
15933 212037 circle_x = zc::math::Cos(a2+PI/2)*abs(dmisc29);
15934 212037 circle_y = -zc::math::Sin(a2+PI/2)*abs(dmisc29);
15935
15936
2/2
✓ Branch 0 taken 121041 times.
✓ Branch 1 taken 90996 times.
212037 if(loopcnt>0)
15937 {
15938 121041 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc29);
15939
1/2
✓ Branch 0 taken 121041 times.
✗ Branch 1 not taken.
121041 guys.spr(i)->y = (-zc::math::Sin(a2+PI/2)-zc::math::Cos(pos2*PI*2/(dmisc1 == 0 ? 1 : dmisc1)))*abs(dmisc31);
15940 121041 }
15941 else
15942 {
15943 90996 guys.spr(i)->x = circle_x;
15944 90996 guys.spr(i)->y = circle_y;
15945 }
15946
15947 212037 temp_x=circle_x;
15948 212037 temp_y=circle_y;
15949 }
15950
15951 double _MSVC2022_tmp1, _MSVC2022_tmp2;
15952 659620 double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x));
15953
15954
4/4
✓ Branch 0 taken 124008 times.
✓ Branch 1 taken 535612 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 83117 times.
659620 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
15955 {
15956 83117 guys.spr(i)->dir=l_down;
15957 83117 }
15958
4/4
✓ Branch 0 taken 124459 times.
✓ Branch 1 taken 452044 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 83568 times.
576503 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
15959 {
15960 83568 guys.spr(i)->dir=left;
15961 83568 }
15962
4/4
✓ Branch 0 taken 123345 times.
✓ Branch 1 taken 369590 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 82454 times.
492935 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
15963 {
15964 82454 guys.spr(i)->dir=l_up;
15965 82454 }
15966
4/4
✓ Branch 0 taken 123079 times.
✓ Branch 1 taken 287402 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 82188 times.
410481 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
15967 {
15968 82188 guys.spr(i)->dir=up;
15969 82188 }
15970
4/4
✓ Branch 0 taken 122491 times.
✓ Branch 1 taken 205802 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 81600 times.
328293 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
15971 {
15972 81600 guys.spr(i)->dir=r_up;
15973 81600 }
15974
4/4
✓ Branch 0 taken 122884 times.
✓ Branch 1 taken 123809 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 81993 times.
246693 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
15975 {
15976 81993 guys.spr(i)->dir=right;
15977 81993 }
15978
4/4
✓ Branch 0 taken 122590 times.
✓ Branch 1 taken 42110 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 81699 times.
164700 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
15979 {
15980 81699 guys.spr(i)->dir=r_down;
15981 81699 }
15982 else
15983 {
15984 83001 guys.spr(i)->dir=down;
15985 }
15986
15987 659620 guys.spr(i)->x += x;
15988 659620 guys.spr(i)->y += y;
15989 }
15990 660384 }
15991
15992
7/22
✓ Branch 0 taken 106957 times.
✓ Branch 1 taken 53484 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 106957 times.
✓ Branch 4 taken 21153 times.
✓ Branch 5 taken 32331 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 21153 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 32331 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
160441 if((wpn>wEnemyWeapons || (wpn >= wScript1 && wpn <= wScript10)) && (dmisc5==1 || dmisc5== 3) && (!dmisc25 || (dmisc25 == 1 && !flycnt && !flycnt2) || (dmisc25 == 2 && (flycnt || flycnt2)) || (dmisc25 == 3 && flycnt2 && !flycnt)))
15993 {
15994 32331 int timeneeded = 48;
15995 32331 int patbreath = (zc_oldrand()%50+50);
15996
2/2
✓ Branch 0 taken 24549 times.
✓ Branch 1 taken 7782 times.
32331 if ((patbreath % 4) == 0) ++patbreath;
15997
1/2
✓ Branch 0 taken 32331 times.
✗ Branch 1 not taken.
32331 if (dmisc28 == patratBREATH)
15998 {
15999 timeneeded = 48 + patbreath;
16000 }
16001
1/2
✓ Branch 0 taken 32331 times.
✗ Branch 1 not taken.
32331 if (dmisc28 == patratSTREAM)
16002 {
16003 timeneeded = 48 + 96;
16004 }
16005
4/14
✓ Branch 0 taken 32331 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 32331 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 249 times.
✓ Branch 11 taken 249 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
32331 if (((((dmisc18 > 0 || ((editorflags & ENEMY_FLAG10) && !flycnt && !flycnt2)) && !(zc_oldrand() % zc_max(dmisc18, 1))) || //New 1/N chance
16006
2/2
✓ Branch 0 taken 32331 times.
✓ Branch 1 taken 249 times.
32580 (dmisc18 == 0 && !(zc_oldrand()&127)) //Old hardcoded firing chance
16007
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 32082 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
32580 || (dmisc18 == -1 && loopcnt > 0 && (clk2 == round(halfsize) && (!(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES))
16008 || (clk4 == 10 && (editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)))))
16009 249 && (clk6 >= 0) //if not in the middle of firing...
16010 249 && clk6 >= dmisc19) //if over the set cooldown between shots...
16011
2/6
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 249 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
249 && ((!(editorflags & ENEMY_FLAG7) || (loopcnt == 0 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > timeneeded)) || dmisc18 == -1)) //And lastly, if not in danger of starting a loop during the attack.
16012 {
16013
1/3
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
249 switch(dmisc28)
16014 {
16015 case patratSTREAM:
16016 {
16017 clk7 = 97;
16018 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)) clk6 = -48;
16019 else clk6 = 0;
16020 break;
16021 }
16022 case patratBREATH:
16023 {
16024 clk7 = patbreath;
16025 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)) clk6 = -48;
16026 else clk6 = 0;
16027 break;
16028 }
16029 default:
16030 {
16031
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 249 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
249 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
16032 {
16033 clk6 = -48;
16034 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
16035 }
16036 else
16037 {
16038 249 clk6 = 0;
16039
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if (editorflags & ENEMY_FLAG6) clk4 = 16;
16040 249 FirePatraWeapon();
16041 }
16042 249 break;
16043 }
16044 } //ew->setAngle(atan2(double(HeroY()-y),double(HeroX()-x)));
16045 249 }
16046
1/2
✓ Branch 0 taken 32331 times.
✗ Branch 1 not taken.
32331 if (clk6 < 0)
16047 {
16048 switch(dmisc28)
16049 {
16050 case patratSTREAM:
16051 {
16052 if (clk7 > 0 && (clk7 % 12) == 0) FirePatraWeapon();
16053 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
16054 break;
16055 }
16056 case patratBREATH:
16057 {
16058 if (clk7 > 0 && (clk7 % 4) == 0) FirePatraWeapon();
16059 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
16060 break;
16061 }
16062 default:
16063 {
16064 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) && clk6 == -16)
16065 {
16066 FirePatraWeapon();
16067 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
16068 }
16069 break;
16070 }
16071 }
16072 }
16073 32331 }
16074
16075 160441 int randattempts = 0;
16076 160441 int randeye = 0;
16077
2/2
✓ Branch 0 taken 114201 times.
✓ Branch 1 taken 46240 times.
160441 if (flycnt2 > 0)
16078 {
16079 46240 do
16080 {
16081
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 46240 times.
✓ Branch 2 taken 44221 times.
✓ Branch 3 taken 2019 times.
46240 randeye = ((flycnt2 > 0) ? (zc_oldrand() % zc_max(1, flycnt2)) : 0);
16082 46240 randeye += (index + flycnt + 1);
16083 46240 ++randattempts;
16084
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 46240 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 46240 times.
46240 } while (((esPatra*)guys.spr(randeye))->clk5 < 0 && randattempts < 10);
16085 46240 }
16086 160441 bool dofire = false;
16087
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (dmisc20)
16088 {
16089 if ((dmisc18 > 0 && !(zc_oldrand() % zc_max(dmisc18, 1))) ||
16090 (dmisc18 == 0 && !(zc_oldrand()&127)) ||
16091 (dmisc18 == -1 && (loopcnt > 0 || dmisc20 == 4) && ((clk2 == round(halfsize) && (!(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES)) && dmisc20 != 2 && dmisc20 != 4)
16092 || (clk2 == 10 && dmisc20 != 4 && ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) || dmisc20 == 2))
16093 || ((((((misc%dmisc6) == 0 && (loopcnt == 0 && !dmisc21)) || loopcnt > 1 || loopcnt == -1) && clk2 <= 53 && clk2 >= 51 && (editorflags & ENEMY_FLAG3)) || (!(editorflags & ENEMY_FLAG3) && loopcnt > 0 && clk2 == 1)) && dmisc20 == 4))))
16094 {
16095 if (clk5 >= 0 || !(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES))
16096 {
16097 if (clk5 >= dmisc19)
16098 {
16099 if ((!(editorflags & ENEMY_FLAG7) || (loopcnt == 0 &&
16100 (dmisc20 == 2 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > ((int64_t)48 + (int64_t(12)*flycnt2))) ||
16101 (dmisc20 == 4 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > ((int64_t)48 + 96)) ||
16102 (dmisc20 != 2 && dmisc20 != 4 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > 48)))
16103 || dmisc18 == -1)
16104 dofire = true;
16105 }
16106 }
16107 }
16108 }
16109
2/2
✓ Branch 0 taken 114201 times.
✓ Branch 1 taken 46240 times.
160441 if(flycnt2)
16110 {
16111
2/2
✓ Branch 0 taken 334429 times.
✓ Branch 1 taken 46240 times.
380669 for(int32_t i=index+flycnt+1; i<index+flycnt+flycnt2+1; i++)//inner ring
16112 {
16113
2/2
✓ Branch 0 taken 334117 times.
✓ Branch 1 taken 312 times.
334429 if(!adjusted)
16114 {
16115 312 ((enemy*)guys.spr(i))->hp=12*game->get_hero_dmgmult();
16116
16117
1/2
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
312 if(get_qr(qr_NEWENEMYTILES))
16118 {
16119
1/2
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
312 if (get_qr(qr_PATRAS_USE_HARDCODED_OFFSETS))
16120 {
16121
2/3
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 168 times.
✗ Branch 2 not taken.
312 switch(dmisc5)
16122 {
16123 // Center eye shoots projectiles; make room for its firing tiles
16124 case 1:
16125 case 3:
16126 144 ((enemy*)guys.spr(i))->o_tile=d->e_tile+120;
16127 144 break;
16128
16129 // Center eyes does not shoot; use tiles two rows below for inner eyes.
16130 default:
16131 case 2:
16132 168 ((enemy*)guys.spr(i))->o_tile=d->e_tile+40;
16133 168 break;
16134 }
16135 312 }
16136 else ((enemy*)guys.spr(i))->o_tile = d->s_tile;
16137 312 }
16138 else
16139 {
16140 ((enemy*)guys.spr(i))->o_tile=o_tile+1;
16141 }
16142
16143 312 ((enemy*)guys.spr(i))->cs=dmisc9;
16144
1/2
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
312 if (dmisc27) ((enemy*)guys.spr(i))->hp=dmisc27;
16145 312 }
16146
16147
2/2
✓ Branch 0 taken 263816 times.
✓ Branch 1 taken 70613 times.
334429 if(flycnt>0)
16148 {
16149 263816 ((enemy*)guys.spr(i))->superman=true;
16150 263816 }
16151 else
16152 {
16153 70613 ((enemy*)guys.spr(i))->superman=false;
16154 }
16155
16156
2/2
✓ Branch 0 taken 145 times.
✓ Branch 1 taken 334284 times.
334429 if(((enemy*)guys.spr(i))->hp <= 0)
16157 {
16158
2/2
✓ Branch 0 taken 269 times.
✓ Branch 1 taken 145 times.
414 for(int32_t j=i; j<index+flycnt+flycnt2; j++)
16159 {
16160 269 guys.swap(j,j+1);
16161 269 }
16162
16163
3/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 127 times.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
145 if (--flycnt2 == 0 && dmisc24 != 0) step += zslongToFix(dmisc24*100);
16164 145 }
16165 else
16166 {
16167 334284 int32_t pos2 = ((enemy*)guys.spr(i))->misc;
16168
1/2
✓ Branch 0 taken 334284 times.
✗ Branch 1 not taken.
334284 double a2 = ((clk2-pos2*basesize/(dmisc2==0 ? 1 : dmisc2))*PI/(halfsize));
16169
16170
2/2
✓ Branch 0 taken 7259 times.
✓ Branch 1 taken 327025 times.
334284 if(dmisc4==0)
16171 {
16172
2/2
✓ Branch 0 taken 168378 times.
✓ Branch 1 taken 158647 times.
327025 if(loopcnt>0)
16173 {
16174
1/2
✓ Branch 0 taken 168378 times.
✗ Branch 1 not taken.
168378 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc32) - zc::math::Sin(pos2*PI*2/(dmisc2==0?1:dmisc2))*((int64_t)abs(dmisc32)-abs(dmisc30));
16175
1/2
✓ Branch 0 taken 168378 times.
✗ Branch 1 not taken.
168378 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc32) + zc::math::Cos(pos2*PI*2/(dmisc2==0?1:dmisc2))*((int64_t)abs(dmisc32)-abs(dmisc30));
16176 168378 }
16177 else
16178 {
16179 158647 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc30);
16180 158647 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc30);
16181 }
16182
16183 327025 temp_x=guys.spr(i)->x;
16184 327025 temp_y=guys.spr(i)->y;
16185 327025 }
16186 else
16187 {
16188 7259 circle_x = zc::math::Cos(a2+PI/2)*abs(dmisc30);
16189 7259 circle_y = -zc::math::Sin(a2+PI/2)*abs(dmisc30);
16190
16191
2/2
✓ Branch 0 taken 3965 times.
✓ Branch 1 taken 3294 times.
7259 if(loopcnt>0)
16192 {
16193 3965 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc30);
16194
1/2
✓ Branch 0 taken 3965 times.
✗ Branch 1 not taken.
3965 guys.spr(i)->y = (-zc::math::Sin(a2+PI/2)-zc::math::Cos(pos2*PI*2/(dmisc2 == 0 ? 1 : dmisc2)))*abs(dmisc32);
16195 3965 }
16196 else
16197 {
16198 3294 guys.spr(i)->x = circle_x;
16199 3294 guys.spr(i)->y = circle_y;
16200 }
16201
16202 7259 temp_x=circle_x;
16203 7259 temp_y=circle_y;
16204 }
16205
16206 double _MSVC2022_tmp1, _MSVC2022_tmp2;
16207 334284 double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x));
16208
16209
4/4
✓ Branch 0 taken 61619 times.
✓ Branch 1 taken 272665 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41746 times.
334284 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
16210 {
16211 41746 guys.spr(i)->dir=l_down;
16212 41746 }
16213
4/4
✓ Branch 0 taken 61607 times.
✓ Branch 1 taken 230931 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41734 times.
292538 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
16214 {
16215 41734 guys.spr(i)->dir=left;
16216 41734 }
16217
4/4
✓ Branch 0 taken 61615 times.
✓ Branch 1 taken 189189 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41742 times.
250804 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
16218 {
16219 41742 guys.spr(i)->dir=l_up;
16220 41742 }
16221
4/4
✓ Branch 0 taken 61631 times.
✓ Branch 1 taken 147431 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41758 times.
209062 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
16222 {
16223 41758 guys.spr(i)->dir=up;
16224 41758 }
16225
4/4
✓ Branch 0 taken 61703 times.
✓ Branch 1 taken 105601 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41830 times.
167304 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
16226 {
16227 41830 guys.spr(i)->dir=r_up;
16228 41830 }
16229
4/4
✓ Branch 0 taken 61697 times.
✓ Branch 1 taken 63777 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41824 times.
125474 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
16230 {
16231 41824 guys.spr(i)->dir=right;
16232 41824 }
16233
4/4
✓ Branch 0 taken 61725 times.
✓ Branch 1 taken 21925 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41852 times.
83650 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
16234 {
16235 41852 guys.spr(i)->dir=r_down;
16236 41852 }
16237 else
16238 {
16239 41798 guys.spr(i)->dir=down;
16240 }
16241
16242 334284 guys.spr(i)->x += x;
16243 334284 guys.spr(i)->y = y-guys.spr(i)->y;
16244
16245
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 334284 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 189016 times.
✓ Branch 5 taken 145268 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 189016 times.
334284 if((wpn>wEnemyWeapons || (wpn >= wScript1 && wpn <= wScript10)) && (dmisc5==2 || dmisc5== 3))
16246 {
16247 /*
16248 if(!(zc_oldrand()&127))
16249 {
16250 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID());
16251 sfx(wpnsfx(wpn),pan(int32_t(x)));
16252 }
16253 */
16254
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 145268 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
145268 if (((esPatra*)guys.spr(i))->clk5 < 0 && (editorflags & ENEMY_FLAG3))
16255 {
16256 if (((esPatra*)guys.spr(i))->clk4 <= 0 || ((esPatra*)guys.spr(i))->clk5 != -16) ++((esPatra*)guys.spr(i))->clk5;
16257 if (get_qr(qr_PATRAS_USE_HARDCODED_OFFSETS))
16258 {
16259 if (dmisc5 == 3)
16260 {
16261 if (((esPatra*)guys.spr(i))->clk5 >= 0) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+120;
16262 else if (((esPatra*)guys.spr(i))->clk5 >= -16) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+200;
16263 else if (((esPatra*)guys.spr(i))->clk5 >= -48) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+160;
16264 else ((esPatra*)guys.spr(i))->o_tile=d->e_tile+120;
16265 }
16266 else
16267 {
16268 if (((esPatra*)guys.spr(i))->clk5 >= 0) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+40;
16269 else if (((esPatra*)guys.spr(i))->clk5 >= -16) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+120;
16270 else if (((esPatra*)guys.spr(i))->clk5 >= -48) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+80;
16271 else ((esPatra*)guys.spr(i))->o_tile=d->e_tile+40;
16272 }
16273 }
16274 else
16275 {
16276 if (((esPatra*)guys.spr(i))->clk5 >= 0) ((esPatra*)guys.spr(i))->o_tile=d->s_tile;
16277 else if (((esPatra*)guys.spr(i))->clk5 >= -16) ((esPatra*)guys.spr(i))->o_tile=d->s_tile+80;
16278 else if (((esPatra*)guys.spr(i))->clk5 >= -48) ((esPatra*)guys.spr(i))->o_tile=d->s_tile+40;
16279 else ((esPatra*)guys.spr(i))->o_tile=d->s_tile;
16280 }
16281 }
16282
4/6
✓ Branch 0 taken 145268 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 145268 times.
✓ Branch 4 taken 145268 times.
✓ Branch 5 taken 145268 times.
145268 else if ((dmisc19 || ((esPatra*)guys.spr(i))->clk5) && (((esPatra*)guys.spr(i))->clk4 <= 0 || ((esPatra*)guys.spr(i))->clk5 != -16)) ++((esPatra*)guys.spr(i))->clk5;
16283
1/2
✓ Branch 0 taken 145268 times.
✗ Branch 1 not taken.
145268 if (((esPatra*)guys.spr(i))->clk4 > 0) --((esPatra*)guys.spr(i))->clk4;
16284
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 145268 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
145268 if (!dmisc25 || (dmisc25 == 1 && !((enemy*)guys.spr(i))->superman) || ((dmisc25 == 2 || dmisc25 == 3) && ((enemy*)guys.spr(i))->superman))
16285 {
16286
1/5
✓ Branch 0 taken 145268 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
145268 switch(dmisc20) //Patra Attack Patterns
16287 {
16288 case 4: //Single one rapidfires
16289 {
16290 if (dofire && i == randeye)
16291 {
16292 ((esPatra*)guys.spr(i))->clk5 = -16;
16293 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)) ((esPatra*)guys.spr(i))->clk5 = -48;
16294 ((esPatra*)guys.spr(i))->clk4 = 96;
16295 clk5 = -3;
16296 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk5) + 16;
16297 }
16298 if (((esPatra*)guys.spr(i))->clk5 == -16 && (((esPatra*)guys.spr(i))->clk4 % 12) == 0)
16299 {
16300 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
16301 sfx(wpnsfx(wpn),pan(int32_t(x)));
16302 }
16303 break;
16304 }
16305 case 3: //Ring
16306 {
16307 if (dofire)
16308 {
16309 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
16310 {
16311 ((esPatra*)guys.spr(i))->clk5 = -48;
16312 clk5 = -48;
16313 if (editorflags & ENEMY_FLAG6) clk4 = 64;
16314 }
16315 else
16316 {
16317 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
16318 sfx(wpnsfx(wpn),pan(int32_t(x)));
16319 int32_t m=Ewpns.Count()-1;
16320 weapon *ew = (weapon*)(Ewpns.spr(m));
16321
16322 ew->setAngle(atan2(double(HeroY()-y),double(HeroX()-x)));
16323 ((esPatra*)guys.spr(i))->clk5 = 0;
16324 clk5 = 0;
16325 if (editorflags & ENEMY_FLAG6) clk4 = 16;
16326 }
16327 }
16328 if (((esPatra*)guys.spr(i))->clk5 == -16)
16329 {
16330 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
16331 sfx(wpnsfx(wpn),pan(int32_t(x)));
16332 int32_t m=Ewpns.Count()-1;
16333 weapon *ew = (weapon*)(Ewpns.spr(m));
16334
16335 ew->setAngle(atan2(double(HeroY()-y),double(HeroX()-x)));
16336 }
16337 break;
16338 }
16339 case 2: //one after another
16340 {
16341 if (dofire)
16342 {
16343 ((esPatra*)guys.spr(i))->clk5 = -48 - (12*(i-(index+flycnt+1)));
16344 clk5 = -48 - (12*flycnt2);
16345 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk5) + 16;
16346 }
16347 if (((esPatra*)guys.spr(i))->clk5 == -16)
16348 {
16349 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
16350 sfx(wpnsfx(wpn),pan(int32_t(x)));
16351 }
16352 break;
16353 }
16354 case 1: //random one eye
16355 {
16356 if (dofire && i == randeye)
16357 {
16358 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
16359 {
16360 ((esPatra*)guys.spr(i))->clk5 = -48;
16361 clk5 = -48;
16362 if (editorflags & ENEMY_FLAG6) clk4 = 64;
16363 }
16364 else
16365 {
16366 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
16367 sfx(wpnsfx(wpn),pan(int32_t(x)));
16368 ((esPatra*)guys.spr(i))->clk5 = 0;
16369 clk5 = 0;
16370 if (editorflags & ENEMY_FLAG6) clk4 = 16;
16371 }
16372 }
16373 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) && ((esPatra*)guys.spr(i))->clk5 == -16)
16374 {
16375 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
16376 sfx(wpnsfx(wpn),pan(int32_t(x)));
16377 }
16378 break;
16379 }
16380 default: //old behavior, all eyes can fire any time
16381 {
16382
3/8
✓ Branch 0 taken 145268 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1155 times.
✓ Branch 5 taken 1155 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
145268 if ((((dmisc18 && !(zc_oldrand() % zc_max(dmisc18, 1))) ||
16383
3/6
✓ Branch 0 taken 145268 times.
✓ Branch 1 taken 1155 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1155 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
147578 (!dmisc18 && !(zc_oldrand()&127))) && (((esPatra*)guys.spr(i))->clk5 >= 0 || !(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES))
16384
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1155 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1155 && ((esPatra*)guys.spr(i))->clk5 >= dmisc19) && (!(editorflags & ENEMY_FLAG7) || (loopcnt == 0 &&
16385 (dmisc20 != 2 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > 48))))
16386 {
16387
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1155 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1155 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
16388 {
16389 ((esPatra*)guys.spr(i))->clk5 = -48;
16390 if (editorflags & ENEMY_FLAG6) clk4 = 64;
16391 }
16392 else
16393 {
16394 1155 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, fakez);
16395 1155 sfx(wpnsfx(wpn),pan(int32_t(x)));
16396 1155 ((esPatra*)guys.spr(i))->clk5 = 0;
16397
1/2
✓ Branch 0 taken 1155 times.
✗ Branch 1 not taken.
1155 if (editorflags & ENEMY_FLAG6) clk4 = 16;
16398 }
16399 1155 }
16400
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 145268 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
147578 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) && ((esPatra*)guys.spr(i))->clk5 == -16)
16401 {
16402 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, fakez);
16403 sfx(wpnsfx(wpn),pan(int32_t(x)));
16404 }
16405 145268 break;
16406 }
16407 }
16408 145268 }
16409 145268 }
16410
16411 }
16412 334429 }
16413 46240 }
16414
16415 160441 adjusted=true;
16416 160441 return enemy::animate(index);
16417 161885 }
16418
16419 249 void ePatra::FirePatraWeapon()
16420 { //.707
16421 249 int32_t xoff = 0;
16422 249 int32_t yoff = 0;
16423
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if (SIZEflags & OVERRIDE_HIT_WIDTH)
16424 {
16425 xoff += hxofs;
16426 if (weapoverrideFLAGS & OVERRIDE_HIT_WIDTH)
16427 xoff += (hit_width / 2) - (weap_tilew * 8);
16428 else
16429 xoff += (hit_width / 2) - 8;
16430 }
16431
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if (SIZEflags & OVERRIDE_HIT_HEIGHT)
16432 {
16433 yoff += hyofs;
16434 if (weapoverrideFLAGS & OVERRIDE_HIT_HEIGHT)
16435 yoff += (hit_height / 2) - (weap_tileh * 8);
16436 else
16437 yoff += (hit_height / 2) - 8;
16438 }
16439 249 sfx(wpnsfx(wpn),pan(int32_t(x)));
16440 // TODO(crash): check that .add succeeds.
16441
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 249 times.
249 switch (dmisc28)
16442 {
16443 case patrat8SHOT: //Fire Wizzrobe
16444 case patrat4SHOTDIAG:
16445 case patrat4SHOTRAND:
16446 if (dmisc28 != patrat4SHOTRAND || (zc_oldrand()%2)) //if it's the 4 shot rand type, only let it through half the time. Break is within so it doesn't do both, but if it skips this one it'll always do the other one.
16447 {
16448 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,l_up,-1, getUID(),false));
16449 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16450 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16451 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
16452
16453 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,l_down,-1, getUID(),false));
16454 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16455 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16456 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
16457
16458 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,r_up,-1, getUID(),false));
16459 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16460 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16461 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
16462
16463 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,r_down,-1, getUID(),false));
16464 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16465 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16466 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
16467
16468 if (dmisc28 == patrat4SHOTDIAG || dmisc28 == patrat4SHOTRAND) break;
16469 }
16470
16471 [[fallthrough]];
16472 case patrat4SHOTCARD: //Stalfos 3
16473 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,up,-1, getUID(),false));
16474 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16475 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16476 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,down,-1, getUID(),false));
16477 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16478 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16479 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,left,-1, getUID(),false));
16480 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16481 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16482 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,right,-1, getUID(),false));
16483 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16484 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16485 break;
16486
16487 default:
16488 249 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16489
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if (dmisc28 == patratBREATH) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle += (zc_rand(20,-20)/100.0)*PI;
16490 249 double anglestore = ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle;
16491
3/6
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 249 times.
249 if (dmisc28 == patrat1SHOTFAST || dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16492
4/8
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 249 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 249 times.
249 if (dmisc28 == patrat3SHOT || dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOT || dmisc28 == patrat5SHOTFAST)
16493 {
16494 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16495 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore + (double)0.46364761;
16496 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.1180;
16497 if (dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16498 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16499 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore - (double)0.46364761;
16500 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.1180;
16501 if (dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16502 if (dmisc28 == patrat5SHOT || dmisc28 == patrat5SHOTFAST)
16503 {
16504 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16505 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore + (double)0.78539816;
16506 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.4142;
16507 if (dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16508 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16509 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore - (double)0.78539816;
16510 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.4142;
16511 if (dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16512 }
16513 }
16514 249 break;
16515
16516 }
16517 249 sfx(wpnsfx(wpn),pan(int32_t(x)));
16518 //+0.46364761
16519 //11.80
16520 249 }
16521
16522 324242 void ePatra::draw(BITMAP *dest)
16523 {
16524 324242 tile=o_tile;
16525 324242 update_enemy_frame();
16526 324242 enemy::draw(dest);
16527 324242 }
16528
16529 int32_t ePatra::defend(int32_t wpnId, int32_t *power, int32_t edef)
16530 {
16531 int32_t ret = enemy::defend(wpnId, power, edef);
16532
16533 if(ret < 0 && (flycnt||flycnt2))
16534 return 0;
16535
16536 return ret;
16537 }
16538
16539 1733 int32_t ePatra::defendNew(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable)
16540 {
16541 1733 int32_t ret = enemy::defendNew(wpnId, power, edef, unblockable);
16542
16543
6/6
✓ Branch 0 taken 1613 times.
✓ Branch 1 taken 120 times.
✓ Branch 2 taken 779 times.
✓ Branch 3 taken 834 times.
✓ Branch 4 taken 447 times.
✓ Branch 5 taken 332 times.
1733 if(ret < 0 && (flycnt||flycnt2))
16544 1281 return 0;
16545
16546 452 return ret;
16547 1733 }
16548
16549 190 void ePatra::init_size_flags() {
16550 190 SIZEflags = d->SIZEflags;
16551
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
190 if (((SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && txsz > 0) { txsz = txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
16552
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 else if (dmisc10 == 1) { txsz = 2; extend = 3; }
16553 // al_trace("Enemy txsz:%i\n", txsz);
16554
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
190 if (((SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && tysz > 0) { tysz = tysz; if (tysz > 1) extend = 3; }
16555
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 else if (dmisc10 == 1) { tysz = 2; extend = 3; }
16556
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
190 if (((SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0) hit_width = hit_width;
16557
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 else if (dmisc10 == 1) hit_width = 32;
16558
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
190 if (((SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0) hit_height = hit_height;
16559
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
190 if (((SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0) hzsz = hzsz;
16560
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if ((SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = hxofs;
16561
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 else if (dmisc10 == 1) hxofs = -8;
16562
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if ((SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = hyofs;
16563 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
16564
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if ((SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)xofs;
16565
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 else if (dmisc10 == 1) xofs = -8;
16566
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if ((SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
16567 {
16568 yofs = (int32_t)yofs; //This seems to be setting to +48 or something with any value set?! -Z
16569 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
16570 }
16571
1/4
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
190 else if (dmisc10 == 1) yofs = (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset) - 8;
16572
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if (editorflags & ENEMY_FLAG8) misc = 1;
16573
16574
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if ((SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)zofs;
16575
16576 190 }
16577
16578 3312 esPatra::esPatra(zfix X,zfix Y,int32_t Id,int32_t Clk, sprite * prnt) : enemy(X,Y,Id,Clk), parent(prnt)
16579 1656 {
16580 //cs=8;
16581 1656 item_set=0;
16582 1656 misc=clk;
16583 1656 clk4 = 0;
16584 1656 clk5 = 0;
16585 1656 clk = -((misc*21)>>1)-1;
16586
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1656 times.
✓ Branch 2 taken 1656 times.
✗ Branch 3 not taken.
1656 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
16587 1656 hit_width=12;
16588 1656 hit_height=12;
16589 1656 hxofs=2;
16590 1656 hyofs=2;
16591 1656 extend = 0;
16592 1656 txsz = 1;
16593 1656 tysz = 1;
16594 /* //These need to be separate enemy editor fields. This enemy class also its draw altered to correctly support big stuff.
16595 enemy *prntenemy = (enemy *) guys.getByUID(parent->getUID());
16596 int32_t prntSIZEflags = prntenemy->SIZEflags;
16597 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = prntenemy->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
16598 // al_trace("Enemy txsz:%i\n", txsz);
16599 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = prntenemy->tysz; if ( tysz > 1 ) extend = 3; }
16600 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = prntenemy->hxsz;
16601 else
16602 hxsz=12;
16603 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = prntenemy->hysz;
16604 else
16605 hysz=12;
16606 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = prntenemy->hzsz;
16607 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = prntenemy->hxofs;
16608 else
16609 hxofs=2;
16610 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = prntenemy->hyofs;
16611 else hyofs=2;
16612 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
16613 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)prntenemy->xofs;
16614 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
16615 {
16616 yofs = (int32_t)prntenemy->yofs; //This seems to be setting to +48 or something with any value set?! -Z
16617 }
16618
16619 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)prntenemy->zofs;
16620 */
16621 1656 mainguy=count_enemy=false;
16622 1656 bgsfx=-1;
16623 //o_tile=0;
16624
2/4
✓ Branch 0 taken 1656 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1656 times.
✗ Branch 3 not taken.
1656 flags &= (~guy_never_return);
16625 1656 deadsfx = WAV_EDEAD;
16626 1656 hitsfx = WAV_EHIT;
16627 1656 isCore = false;
16628 1656 }
16629
16630 1010584 bool esPatra::animate(int32_t index)
16631 {
16632
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1010584 times.
1010584 if(switch_hooked) return enemy::animate(index);
16633
2/2
✓ Branch 0 taken 15160 times.
✓ Branch 1 taken 995424 times.
1010584 if(dying)
16634 15160 return Dead(index);
16635
16636 995424 return enemy::animate(index);
16637 1010584 }
16638
16639 2028196 void esPatra::draw(BITMAP *dest)
16640 {
16641
2/2
✓ Branch 0 taken 1721294 times.
✓ Branch 1 taken 306902 times.
2028196 if(get_qr(qr_NEWENEMYTILES))
16642 {
16643 1721294 tile = o_tile+(clk&3);
16644
16645
8/9
✓ Branch 0 taken 214278 times.
✓ Branch 1 taken 217924 times.
✓ Branch 2 taken 215346 times.
✓ Branch 3 taken 215726 times.
✓ Branch 4 taken 213062 times.
✓ Branch 5 taken 214350 times.
✓ Branch 6 taken 215734 times.
✓ Branch 7 taken 214874 times.
✗ Branch 8 not taken.
1721294 switch(dir) //directions get screwed up after 8. *shrug*
16646 {
16647 case up: //u
16648 214278 flip=0;
16649 214278 break;
16650
16651 case down: //d
16652 217924 flip=0;
16653 217924 tile+=4;
16654 217924 break;
16655
16656 case left: //l
16657 215346 flip=0;
16658 215346 tile+=8;
16659 215346 break;
16660
16661 case right: //r
16662 215726 flip=0;
16663 215726 tile+=12;
16664 215726 break;
16665
16666 case l_up: //ul
16667 213062 flip=0;
16668 213062 tile+=20;
16669 213062 break;
16670
16671 case r_up: //ur
16672 214350 flip=0;
16673 214350 tile+=24;
16674 214350 break;
16675
16676 case l_down: //dl
16677 215734 flip=0;
16678 215734 tile+=28;
16679 215734 break;
16680
16681 case r_down: //dr
16682 214874 flip=0;
16683 214874 tile+=32;
16684 214874 break;
16685 }
16686 1721294 }
16687 else
16688 {
16689 306902 tile = o_tile+((clk&2)>>1);
16690 }
16691
16692
2/2
✓ Branch 0 taken 114856 times.
✓ Branch 1 taken 1913340 times.
2028196 if(clk>=0)
16693 1913340 enemy::draw(dest);
16694 2028196 }
16695
16696
16697 102 ePatraBS::ePatraBS(zfix ,zfix ,int32_t Id,int32_t Clk) : enemy((zfix)128,(zfix)48,Id,Clk)
16698 102 {
16699 102 adjusted=false;
16700
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 dir=(zc_oldrand()&7)+8;
16701
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 step=0.25;
16702 102 clk4 = 0;
16703 102 clk5 = 0;
16704 //flycnt=6; flycnt2=0;
16705 102 flycnt=dmisc1;
16706 102 flycnt2=0; // PatraBS doesn't have inner rings!
16707 102 loopcnt=0;
16708
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 init_size_flags();
16709
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
102 if(dmisc6<int16_t(1))dmisc6=1; // ratio cannot be 0!
16710
16711 //nets+4480;
16712 102 }
16713
16714 35963 bool ePatraBS::animate(int32_t index)
16715 {
16716
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35963 times.
35963 if(switch_hooked) return enemy::animate(index);
16717
2/2
✓ Branch 0 taken 240 times.
✓ Branch 1 taken 35723 times.
35963 if(dying)
16718 240 return Dead(index);
16719
16720
2/2
✓ Branch 0 taken 31705 times.
✓ Branch 1 taken 4018 times.
35723 if(clk==0)
16721 {
16722 4018 removearmos(x,y,ffcactivated);
16723 4018 }
16724
16725 35723 variable_walk_8(rate,homing,hrate,spw_floater);
16726
16727
2/2
✓ Branch 0 taken 35387 times.
✓ Branch 1 taken 336 times.
35723 if(++clk2>90)
16728 {
16729 336 clk2=0;
16730
16731
2/2
✓ Branch 0 taken 177 times.
✓ Branch 1 taken 159 times.
336 if(loopcnt)
16732 177 --loopcnt;
16733 else
16734 {
16735
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 75 times.
159 if((misc%dmisc6)==0)
16736 84 loopcnt=dmisc7;
16737 }
16738
16739 336 ++misc;
16740 336 }
16741
16742 // double size=1;;
16743
2/2
✓ Branch 0 taken 153472 times.
✓ Branch 1 taken 35723 times.
189195 for(int32_t i=index+1; i<index+flycnt+1; i++)
16744 {
16745
2/2
✓ Branch 0 taken 152860 times.
✓ Branch 1 taken 612 times.
153472 if(!adjusted)
16746 {
16747 612 ((enemy*)guys.spr(i))->hp=dmisc3;
16748
16749
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 if(get_qr(qr_NEWENEMYTILES))
16750 {
16751 612 ((enemy*)guys.spr(i))->o_tile=o_tile+dmisc8;
16752 612 }
16753 else
16754 {
16755 ((enemy*)guys.spr(i))->o_tile=o_tile+1;
16756 }
16757
16758 612 ((enemy*)guys.spr(i))->cs = dmisc9;
16759 612 }
16760
16761
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 153368 times.
153472 if(((enemy*)guys.spr(i))->hp <= 0)
16762 {
16763
2/2
✓ Branch 0 taken 131 times.
✓ Branch 1 taken 104 times.
235 for(int32_t j=i; j<index+flycnt+flycnt2; j++)
16764 {
16765 131 guys.swap(j,j+1);
16766 131 }
16767
16768 104 --flycnt;
16769 104 }
16770 else
16771 {
16772 153368 int32_t pos2 = ((enemy*)guys.spr(i))->misc;
16773
1/2
✓ Branch 0 taken 153368 times.
✗ Branch 1 not taken.
153368 double a2 = ((int64_t)clk2-pos2*90/(dmisc1==0?1:dmisc1))*PI/45;
16774 153368 temp_x = zc::math::Cos(a2+PI/2)*45;
16775 153368 temp_y = -zc::math::Sin(a2+PI/2)*45;
16776
16777
2/2
✓ Branch 0 taken 77643 times.
✓ Branch 1 taken 75725 times.
153368 if(loopcnt>0)
16778 {
16779 77643 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*45;
16780
1/2
✓ Branch 0 taken 77643 times.
✗ Branch 1 not taken.
77643 guys.spr(i)->y = (-zc::math::Sin(a2+PI/2)-zc::math::Cos(pos2*PI*2/(dmisc1==0?1:dmisc1)))*22.5;
16781 77643 }
16782 else
16783 {
16784 75725 guys.spr(i)->x = temp_x;
16785 75725 guys.spr(i)->y = temp_y;
16786 }
16787
16788 double _MSVC2022_tmp1, _MSVC2022_tmp2;
16789 153368 double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x));
16790
16791
4/4
✓ Branch 0 taken 29178 times.
✓ Branch 1 taken 124190 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18812 times.
153368 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
16792 {
16793 18812 guys.spr(i)->dir=l_down;
16794 18812 }
16795
4/4
✓ Branch 0 taken 29205 times.
✓ Branch 1 taken 105351 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18839 times.
134556 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
16796 {
16797 18839 guys.spr(i)->dir=left;
16798 18839 }
16799
4/4
✓ Branch 0 taken 29168 times.
✓ Branch 1 taken 86549 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18802 times.
115717 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
16800 {
16801 18802 guys.spr(i)->dir=l_up;
16802 18802 }
16803
4/4
✓ Branch 0 taken 30509 times.
✓ Branch 1 taken 66406 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 20143 times.
96915 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
16804 {
16805 20143 guys.spr(i)->dir=up;
16806 20143 }
16807
4/4
✓ Branch 0 taken 28883 times.
✓ Branch 1 taken 47889 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18517 times.
76772 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
16808 {
16809 18517 guys.spr(i)->dir=r_up;
16810 18517 }
16811
4/4
✓ Branch 0 taken 29145 times.
✓ Branch 1 taken 29110 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18779 times.
58255 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
16812 {
16813 18779 guys.spr(i)->dir=right;
16814 18779 }
16815
4/4
✓ Branch 0 taken 29358 times.
✓ Branch 1 taken 10118 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18992 times.
39476 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
16816 {
16817 18992 guys.spr(i)->dir=r_down;
16818 18992 }
16819 else
16820 {
16821 20484 guys.spr(i)->dir=down;
16822 }
16823
16824 153368 guys.spr(i)->x += x;
16825 153368 guys.spr(i)->y += y;
16826 }
16827 153472 }
16828
16829 35723 adjusted=true;
16830 35723 return enemy::animate(index);
16831 35963 }
16832
16833 72874 void ePatraBS::draw(BITMAP *dest)
16834 {
16835 72874 tile=o_tile;
16836
16837
1/2
✓ Branch 0 taken 72874 times.
✗ Branch 1 not taken.
72874 if(get_qr(qr_NEWENEMYTILES))
16838 {
16839 double _MSVC2022_tmp1, _MSVC2022_tmp2;
16840 72874 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
16841
16842
4/4
✓ Branch 0 taken 27164 times.
✓ Branch 1 taken 45710 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 19146 times.
72874 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
16843 {
16844 19146 lookat=l_down;
16845 19146 }
16846
4/4
✓ Branch 0 taken 26316 times.
✓ Branch 1 taken 27412 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 18298 times.
53728 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
16847 {
16848 18298 lookat=down;
16849 18298 }
16850
4/4
✓ Branch 0 taken 21642 times.
✓ Branch 1 taken 13788 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 13624 times.
35430 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
16851 {
16852 13624 lookat=r_down;
16853 13624 }
16854
4/4
✓ Branch 0 taken 15510 times.
✓ Branch 1 taken 6296 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 7492 times.
21806 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
16855 {
16856 7492 lookat=right;
16857 7492 }
16858
4/4
✓ Branch 0 taken 9188 times.
✓ Branch 1 taken 5126 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 1170 times.
14314 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
16859 {
16860 1170 lookat=r_up;
16861 1170 }
16862
4/4
✓ Branch 0 taken 8982 times.
✓ Branch 1 taken 4162 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 964 times.
13144 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
16863 {
16864 964 lookat=up;
16865 964 }
16866
4/4
✓ Branch 0 taken 9718 times.
✓ Branch 1 taken 2462 times.
✓ Branch 2 taken 1700 times.
✓ Branch 3 taken 8018 times.
12180 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
16867 {
16868 1700 lookat=l_up;
16869 1700 }
16870 else
16871 {
16872 10480 lookat=left;
16873 }
16874
16875
8/9
✗ Branch 0 not taken.
✓ Branch 1 taken 964 times.
✓ Branch 2 taken 18298 times.
✓ Branch 3 taken 10480 times.
✓ Branch 4 taken 7492 times.
✓ Branch 5 taken 1700 times.
✓ Branch 6 taken 1170 times.
✓ Branch 7 taken 19146 times.
✓ Branch 8 taken 13624 times.
72874 switch(lookat) //directions get screwed up after 8. *shrug*
16876 {
16877 case up: //u
16878 964 flip=0;
16879 964 break;
16880
16881 case down: //d
16882 18298 flip=0;
16883 18298 tile+=8;
16884 18298 break;
16885
16886 case left: //l
16887 10480 flip=0;
16888 10480 tile+=40;
16889 10480 break;
16890
16891 case right: //r
16892 7492 flip=0;
16893 7492 tile+=48;
16894 7492 break;
16895
16896 case l_up: //ul
16897 1700 flip=0;
16898 1700 tile+=80;
16899 1700 break;
16900
16901 case r_up: //ur
16902 1170 flip=0;
16903 1170 tile+=88;
16904 1170 break;
16905
16906 case l_down: //dl
16907 19146 flip=0;
16908 19146 tile+=120;
16909 19146 break;
16910
16911 case r_down: //dr
16912 13624 flip=0;
16913 13624 tile+=128;
16914 13624 break;
16915 }
16916
16917 72874 tile+=(2*(clk&3));
16918 72874 xofs-=8;
16919 72874 yofs-=8;
16920 72874 drawblock(dest,15);
16921 72874 xofs+=8;
16922 72874 yofs+=8;
16923 72874 }
16924 else
16925 {
16926 flip=(clk&1);
16927 xofs-=8;
16928 yofs-=8;
16929 enemy::draw(dest);
16930 xofs+=16;
16931 enemy::draw(dest);
16932 yofs+=16;
16933 enemy::draw(dest);
16934 xofs-=16;
16935 enemy::draw(dest);
16936 xofs+=8;
16937 yofs-=8;
16938 }
16939 72874 }
16940
16941 int32_t ePatraBS::defend(int32_t wpnId, int32_t *power, int32_t edef)
16942 {
16943 int32_t ret = enemy::defend(wpnId, power, edef);
16944
16945 if(ret < 0 && (flycnt||flycnt2))
16946 return 0;
16947
16948 return ret;
16949 }
16950
16951 142 int32_t ePatraBS::defendNew(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable)
16952 {
16953 142 int32_t ret = enemy::defendNew(wpnId, power, edef, unblockable);
16954
16955
5/6
✓ Branch 0 taken 141 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 60 times.
✓ Branch 3 taken 81 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 60 times.
142 if(ret < 0 && (flycnt||flycnt2))
16956 81 return 0;
16957
16958 61 return ret;
16959 142 }
16960
16961 102 void ePatraBS::init_size_flags()
16962 {
16963 102 SIZEflags = d->SIZEflags;
16964
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
102 if (((SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
16965 // al_trace("Enemy txsz:%i\n", txsz);
16966
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
102 if (((SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
16967
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
102 if (((SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0) hit_width = d->hxsz;
16968 102 else hit_width = 32;
16969
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
102 if (((SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0) hit_height = d->hysz;
16970
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
102 if (((SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0) hzsz = d->hzsz;
16971
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
102 if ((SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
16972 102 else hxofs = -8;
16973
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if ((SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
16974 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
16975
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if ((SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)d->xofs;
16976
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if ((SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
16977 {
16978 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
16979 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
16980 }
16981
16982
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if ((SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)d->zofs;
16983 102 }
16984
16985 1224 esPatraBS::esPatraBS(zfix X,zfix Y,int32_t Id,int32_t Clk, sprite * prnt) : enemy(X,Y,Id,Clk), parent(prnt)
16986 612 {
16987 //cs=csBOSS;
16988 612 item_set=0;
16989 612 misc=clk;
16990 612 clk = -((misc*21)>>1)-1;
16991 612 clk4 = 0;
16992 612 clk5 = 0;
16993
2/4
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 612 times.
✗ Branch 3 not taken.
612 enemy *prntenemy = (enemy *) guys.getByUID(parent->getUID());
16994 612 int32_t prntSIZEflags = prntenemy->SIZEflags;
16995
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
612 if ( ((prntSIZEflags&OVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = prntenemy->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
16996 // al_trace("Enemy txsz:%i\n", txsz);
16997
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
612 if ( ((prntSIZEflags&OVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = prntenemy->tysz; if ( tysz > 1 ) extend = 3; }
16998
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
612 if ( ((prntSIZEflags&OVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = prntenemy->hit_width;
16999 612 else hit_width=16;
17000
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
612 if ( ((prntSIZEflags&OVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = prntenemy->hit_height;
17001 612 else hit_height=16;
17002
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
612 if ( ((prntSIZEflags&OVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = prntenemy->hzsz;
17003
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 if ( (prntSIZEflags&OVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = prntenemy->hxofs;
17004
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
612 if ( (prntSIZEflags&OVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = prntenemy->hyofs;
17005 612 else hyofs=2;
17006 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
17007
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
612 if ( (prntSIZEflags&OVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)prntenemy->xofs;
17008
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
612 if ( (prntSIZEflags&OVERRIDE_DRAW_Y_OFFSET) != 0 )
17009 {
17010 yofs = (int32_t)prntenemy->yofs;
17011 }
17012
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✓ Branch 2 taken 612 times.
✗ Branch 3 not taken.
612 else yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
17013
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
612 if ( (prntSIZEflags&OVERRIDE_DRAW_Z_OFFSET) != 0 ) prntenemy->zofs = (int32_t)zofs;
17014
17015 612 bgsfx=-1;
17016 612 mainguy=count_enemy=false;
17017 612 deadsfx = WAV_EDEAD;
17018 612 hitsfx = WAV_EHIT;
17019
2/4
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 612 times.
✗ Branch 3 not taken.
612 flags &= ~guy_never_return;
17020 612 isCore = false;
17021 612 }
17022
17023 155090 bool esPatraBS::animate(int32_t index)
17024 {
17025
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 155090 times.
155090 if(switch_hooked) return enemy::animate(index);
17026
2/2
✓ Branch 0 taken 1552 times.
✓ Branch 1 taken 153538 times.
155090 if(dying)
17027 1552 return Dead(index);
17028
17029 153538 return enemy::animate(index);
17030 155090 }
17031
17032 315868 void esPatraBS::draw(BITMAP *dest)
17033 {
17034 315868 tile=o_tile;
17035
17036
1/2
✓ Branch 0 taken 315868 times.
✗ Branch 1 not taken.
315868 if(get_qr(qr_NEWENEMYTILES))
17037 {
17038
8/9
✓ Branch 0 taken 41612 times.
✓ Branch 1 taken 42622 times.
✓ Branch 2 taken 37916 times.
✓ Branch 3 taken 38458 times.
✓ Branch 4 taken 38564 times.
✓ Branch 5 taken 38568 times.
✓ Branch 6 taken 38662 times.
✓ Branch 7 taken 39466 times.
✗ Branch 8 not taken.
315868 switch(dir) //directions get screwed up after 8. *shrug*
17039 {
17040 case up: //u
17041 41612 flip=0;
17042 41612 break;
17043
17044 case down: //d
17045 42622 flip=0;
17046 42622 tile+=4;
17047 42622 break;
17048
17049 case left: //l
17050 37916 flip=0;
17051 37916 tile+=8;
17052 37916 break;
17053
17054 case right: //r
17055 38458 flip=0;
17056 38458 tile+=12;
17057 38458 break;
17058
17059 case l_up: //ul
17060 38564 flip=0;
17061 38564 tile+=20;
17062 38564 break;
17063
17064 case r_up: //ur
17065 38568 flip=0;
17066 38568 tile+=24;
17067 38568 break;
17068
17069 case l_down: //dl
17070 38662 flip=0;
17071 38662 tile+=28;
17072 38662 break;
17073
17074 case r_down: //dr
17075 39466 flip=0;
17076 39466 tile+=32;
17077 39466 break;
17078 }
17079
17080 315868 tile += ((clk&6)>>1);
17081 315868 }
17082 else
17083 {
17084 tile += (clk&4)?1:0;
17085 }
17086
17087
2/2
✓ Branch 0 taken 32116 times.
✓ Branch 1 taken 283752 times.
315868 if(clk>=0)
17088 283752 enemy::draw(dest);
17089 315868 }
17090
17091 242007 void addEwpn(int32_t x,int32_t y,int32_t z,int32_t id,int32_t type,int32_t power,int32_t dir, int32_t parentid, byte script_generated, int32_t fakez)
17092 {
17093
4/6
✓ Branch 0 taken 135638 times.
✓ Branch 1 taken 106369 times.
✓ Branch 2 taken 135638 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 135638 times.
✗ Branch 5 not taken.
242007 if(id>wEnemyWeapons || (id >= wScript1 && id <= wScript10))
17094
4/8
✓ Branch 0 taken 242007 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 242007 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 242007 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 242007 times.
✗ Branch 7 not taken.
242007 Ewpns.add(new weapon((zfix)x,(zfix)y,(zfix)z,id,type,power,dir, -1, parentid, script_generated));
17095
1/2
✓ Branch 0 taken 242007 times.
✗ Branch 1 not taken.
242007 if (fakez > 0) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
17096 242007 }
17097
17098 74352 int32_t hit_enemy(int32_t index, int32_t wpnId,int32_t power,int32_t wpnx,int32_t wpny,int32_t dir, int32_t enemyHitWeapon, weapon* realweap)
17099 {
17100 // Kludge
17101
4/8
✓ Branch 0 taken 74352 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 74352 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 74352 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 74352 times.
✗ Branch 7 not taken.
74352 weapon *w = new weapon((zfix)wpnx,(zfix)wpny,(zfix)0,wpnId,0,power,dir,enemyHitWeapon,-1,false);
17102 74352 int32_t ret = ((enemy*)guys.spr(index))->takehit(w,realweap);
17103
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74352 times.
74352 delete w;
17104 74352 return ret;
17105 }
17106
17107 9139 void enemy_scored(int32_t index)
17108 {
17109 9139 ((enemy*)guys.spr(index))->scored=true;
17110 9139 }
17111
17112 2181 void addguy(int32_t x,int32_t y,int32_t id,int32_t clk,bool mainguy,mapscr* parentscr)
17113 {
17114
6/10
✓ Branch 0 taken 2181 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2181 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2181 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 275 times.
✓ Branch 7 taken 1906 times.
✓ Branch 8 taken 2181 times.
✗ Branch 9 not taken.
2181 guy *g = new guy((zfix)x,(zfix)(y+(isdungeon()?1:0)),id,get_qr(qr_NOGUYPOOF)?0:clk,mainguy);
17115
5/6
✓ Branch 0 taken 1271 times.
✓ Branch 1 taken 910 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 1267 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
2181 if(parentscr && parentscr->guytile > -1 && !get_qr(qr_OLD_GUY_HANDLING))
17116 {
17117 4 g->o_tile = parentscr->guytile;
17118
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(g->o_tile != 0)
17119 4 g->flags &= ~guy_invisible;
17120 4 g->cs = parentscr->guycs;
17121 4 }
17122 2181 guys.add(g);
17123 2181 }
17124
17125 23569 void additem(int32_t x,int32_t y,int32_t id,int32_t pickup)
17126 {
17127
4/8
✓ Branch 0 taken 23569 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23569 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 23569 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 23569 times.
✗ Branch 7 not taken.
23569 item *i = new item(zfix(x), zfix(y - get_qr(qr_NOITEMOFFSET)), 0_zf, id, pickup, 0);
17128 23569 items.add(i);
17129 23569 }
17130
17131 150 void additem(int32_t x,int32_t y,int32_t id,int32_t pickup,int32_t clk)
17132 {
17133
5/10
✓ Branch 0 taken 150 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 150 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 150 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 150 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 150 times.
✗ Branch 9 not taken.
150 item *i = new item((zfix)x,(zfix)y-(get_qr(qr_NOITEMOFFSET)),(zfix)0,id,pickup,clk);
17134 150 items.add(i);
17135 150 }
17136
17137 3 void adddummyitem(int32_t x,int32_t y,int32_t id,int32_t pickup)
17138 {
17139
5/10
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3 times.
✗ Branch 9 not taken.
3 item *i = new item((zfix)x,(zfix)y-(get_qr(qr_NOITEMOFFSET)),(zfix)0,id,pickup,0,true);
17140 3 items.add(i);
17141 3 }
17142
17143 96 void kill_em_all()
17144 {
17145
2/2
✓ Branch 0 taken 353 times.
✓ Branch 1 taken 96 times.
449 for(int32_t i=0; i<guys.Count(); i++)
17146 {
17147 353 enemy *e = ((enemy*)guys.spr(i));
17148
17149
3/6
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 323 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 30 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
353 if(e->flags&(1<<3) && !(e->family == eeGHINI && e->dmisc1 == 1)) continue;
17150
17151 323 e->kickbucket();
17152 323 }
17153 96 }
17154
17155 bool can_kill_em_all()
17156 {
17157 for(int32_t i=0; i<guys.Count(); i++)
17158 {
17159 enemy *e = ((enemy*)guys.spr(i));
17160
17161 if(e->flags&(1<<3) && !(e->family == eeGHINI && e->dmisc1 == 1)) continue;
17162 if(e->superman) continue;
17163 return true;
17164 }
17165 return false;
17166 }
17167
17168 //This needs a quest rule, or enemy flag, Dying Enemy Doesn't Hurt Hero
17169 // For Hero's hit detection. Don't count them if they are stunned or are guys.
17170 int32_t GuyHit(int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz)
17171 {
17172 for(int32_t i=0; i<guys.Count(); i++)
17173 {
17174 if(guys.spr(i)->hit(tx,ty,tz,txsz,tysz,tzsz))
17175 {
17176 if(((enemy*)guys.spr(i))->stunclk==0 && ((enemy*)guys.spr(i))->frozenclock==0 && (!get_qr(qr_SAFEENEMYFADE) || ((enemy*)guys.spr(i))->fading != fade_flicker)
17177 &&(((enemy*)guys.spr(i))->d->family != eeGUY || ((enemy*)guys.spr(i))->dmisc1))
17178 {
17179 return i;
17180 }
17181 }
17182 }
17183
17184 return -1;
17185 }
17186
17187 13013706 int32_t GuyHitFrom(int32_t index,int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz)
17188 {
17189
4/4
✓ Branch 0 taken 16502 times.
✓ Branch 1 taken 12997204 times.
✓ Branch 2 taken 33612329 times.
✓ Branch 3 taken 12983028 times.
46595357 for(int32_t i=zc_max(0, index); i<guys.Count(); i++)
17190 {
17191
2/2
✓ Branch 0 taken 30678 times.
✓ Branch 1 taken 33581651 times.
33612329 if(guys.spr(i)->hit(tx,ty,tz,txsz,tysz,tzsz))
17192 {
17193 30678 return i;
17194 }
17195 33581651 }
17196
17197 12983028 return -1;
17198 13013706 }
17199
17200 // For Hero's hit detection. Count them if they are dying.
17201 52222 int32_t GuyHit(int32_t index,int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz)
17202 {
17203 52222 enemy *e = (enemy*)guys.spr(index);
17204
3/4
✓ Branch 0 taken 52222 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 27850 times.
✓ Branch 3 taken 24372 times.
52222 if(!e || e->hp > 0)
17205 27850 return -1;
17206
17207 24372 bool d = e->dying;
17208 24372 int32_t hc = e->hclk;
17209 24372 e->dying = false;
17210 24372 e->hclk = 0;
17211 24372 bool hit = e->hit(tx,ty,tz,txsz,tysz,tzsz);
17212 24372 e->dying = d;
17213 24372 e->hclk = hc;
17214
17215
2/2
✓ Branch 0 taken 157 times.
✓ Branch 1 taken 24215 times.
24372 return hit ? index : -1;
17216 52222 }
17217
17218 14174184 bool hasMainGuy()
17219 {
17220
2/2
✓ Branch 0 taken 15399012 times.
✓ Branch 1 taken 5529976 times.
20928988 for(int32_t i=0; i<guys.Count(); i++)
17221 {
17222
2/2
✓ Branch 0 taken 8644208 times.
✓ Branch 1 taken 6754804 times.
15399012 if(((enemy*)guys.spr(i))->mainguy)
17223 {
17224 8644208 return true;
17225 }
17226 6754804 }
17227
17228 5529976 return false;
17229 14174184 }
17230
17231 138 void EatHero(int32_t index)
17232 {
17233 138 ((eStalfos*)guys.spr(index))->eathero();
17234 138 }
17235
17236 9 void GrabHero(int32_t index)
17237 {
17238 9 ((eWallM*)guys.spr(index))->grabhero();
17239 9 }
17240
17241 1338 bool CarryHero()
17242 {
17243
1/2
✓ Branch 0 taken 3933 times.
✗ Branch 1 not taken.
3933 for(int32_t i=0; i<guys.Count(); i++)
17244 {
17245
2/2
✓ Branch 0 taken 2090 times.
✓ Branch 1 taken 1843 times.
3933 if(((guy*)(guys.spr(i)))->family==eeWALLM)
17246 {
17247
2/2
✓ Branch 0 taken 1338 times.
✓ Branch 1 taken 505 times.
1843 if(((eWallM*)guys.spr(i))->hashero)
17248 {
17249 1338 Hero.x=guys.spr(i)->x;
17250 1338 Hero.y=guys.spr(i)->y;
17251 1338 return ((eWallM*)guys.spr(i))->misc > 0;
17252 }
17253 505 }
17254
17255 // Like Likes currently can't carry Hero.
17256 /*
17257 if(((guy*)(guys.spr(i)))->family==eeLIKE)
17258 {
17259 if(((eLikeLike*)guys.spr(i))->hashero)
17260 {
17261 Hero.x=guys.spr(i)->x;
17262 Hero.y=guys.spr(i)->y;
17263 return (true);
17264 }
17265 }*/
17266 2595 }
17267
17268 return false;
17269 1338 }
17270
17271 // Move item with guy
17272 void movefairy(zfix &x,zfix &y,int32_t misc)
17273 {
17274 int32_t i = guys.idFirst(eITEMFAIRY+0x1000*misc);
17275
17276 if(i!=-1)
17277 {
17278 x = guys.spr(i)->x;
17279 y = guys.spr(i)->y;
17280 }
17281 }
17282
17283 // Move guy with item (used by FFC scripts and hookshot-dragged fairies)
17284 void movefairy2(zfix x,zfix y,int32_t misc)
17285 {
17286 int32_t i = guys.idFirst(eITEMFAIRY+0x1000*misc);
17287
17288 if(i!=-1)
17289 {
17290 guys.spr(i)->x = x;
17291 guys.spr(i)->y = y;
17292 }
17293 }// Move item with guy
17294
17295 60438 void movefairynew(zfix &x,zfix &y, item const &itemfairy)
17296 {
17297 60438 enemy *fairy = (enemy *) guys.getByUID(itemfairy.fairyUID);
17298
17299
1/2
✓ Branch 0 taken 60438 times.
✗ Branch 1 not taken.
60438 if(fairy)
17300 {
17301 60438 x = fairy->x;
17302 60438 y = fairy->y;
17303 60438 }
17304 60438 }
17305
17306 // Move guy with item (used by FFC scripts and hookshot-dragged fairies)
17307 404 void movefairynew2(zfix x,zfix y, item const &itemfairy)
17308 {
17309 404 enemy *fairy = (enemy *) guys.getByUID(itemfairy.fairyUID);
17310
17311
1/2
✓ Branch 0 taken 404 times.
✗ Branch 1 not taken.
404 if(fairy)
17312 {
17313 404 fairy->x = x;
17314 404 fairy->y = y;
17315 404 }
17316 404 }
17317
17318 void killfairy(int32_t misc)
17319 {
17320 int32_t i = guys.idFirst(eITEMFAIRY+0x1000*misc);
17321 guys.del(i);
17322 }
17323
17324 217 int32_t getGuyIndex(const int32_t eid)
17325 {
17326
1/2
✓ Branch 0 taken 826 times.
✗ Branch 1 not taken.
826 for(word i = 0; i < guys.Count(); i++)
17327 {
17328
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 609 times.
826 if(guys.spr(i)->getUID() == eid)
17329 217 return i;
17330 609 }
17331
17332 return -1;
17333 217 }
17334
17335 217 void killfairynew(item const &itemfairy)
17336 {
17337 217 enemy *fairy = (enemy *) guys.getByUID(itemfairy.fairyUID);
17338
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if (fairy != NULL) guys.del(getGuyIndex(itemfairy.fairyUID));
17339 217 }
17340
17341 //Should probably change this to return an 'enemy*', null on failure -Em
17342 21718 int32_t addenemy(int32_t x,int32_t y,int32_t id,int32_t clk)
17343 {
17344 21718 return addenemy(x,y,0,id,clk);
17345 }
17346
17347 1965 int32_t addchild(int32_t x,int32_t y,int32_t id,int32_t clk, int32_t parent_scriptUID)
17348 {
17349 1965 return addchild(x,y,0,id,clk, parent_scriptUID);
17350 }
17351
17352 1997 int32_t addchild(int32_t x,int32_t y,int32_t z,int32_t id,int32_t clk, int32_t parent_scriptUID)
17353 {
17354
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1997 times.
1997 if(id <= 0) return 0;
17355
17356 1997 int32_t ret = 0;
17357 1997 sprite *e=NULL;
17358 1997 al_trace("Adding child\n");
17359
17360
6/31
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 110 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1865 times.
✓ Branch 10 taken 15 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 1 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 2 times.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 4 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
1997 switch(guysbuf[id&0xFFF].family)
17361 {
17362 //Fixme: possible enemy memory leak. (minor)
17363 case eeWALK:
17364
3/6
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 110 times.
✗ Branch 5 not taken.
110 e = new eStalfos((zfix)x,(zfix)y,id,clk);
17365 110 break;
17366
17367 case eeLEV:
17368 e = new eLeever((zfix)x,(zfix)y,id,clk);
17369 break;
17370
17371 case eeTEK:
17372 e = new eTektite((zfix)x,(zfix)y,id,clk);
17373 break;
17374
17375 case eePEAHAT:
17376 e = new ePeahat((zfix)x,(zfix)y,id,clk);
17377 break;
17378
17379 case eeZORA:
17380 e = new eZora((zfix)x,(zfix)y,id,clk);
17381 break;
17382
17383 case eeGHINI:
17384 e = new eGhini((zfix)x,(zfix)y,id,clk);
17385 break;
17386
17387 case eeKEESE:
17388
3/6
✓ Branch 0 taken 1865 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1865 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1865 times.
✗ Branch 5 not taken.
1865 e = new eKeese((zfix)x,(zfix)y,id,clk);
17389 1865 break;
17390
17391 case eeWIZZ:
17392
3/6
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
15 e = new eWizzrobe((zfix)x,(zfix)y,id,clk);
17393 15 break;
17394
17395 case eePROJECTILE:
17396 e = new eProjectile((zfix)x,(zfix)y,id,clk);
17397 break;
17398
17399 case eeWALLM:
17400 e = new eWallM((zfix)x,(zfix)y,id,clk);
17401 break;
17402
17403 case eeAQUA:
17404 e = new eAquamentus((zfix)x,(zfix)y,id,clk);
17405 break;
17406
17407 case eeMOLD:
17408 e = new eMoldorm((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])));
17409 break;
17410
17411 case eeMANHAN:
17412
3/6
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 e = new eManhandla((zfix)x,(zfix)y,id,clk);
17413 1 break;
17414
17415 case eeGLEEOK:
17416 e = new eGleeok((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])));
17417 break;
17418
17419 case eeGHOMA:
17420 e = new eGohma((zfix)x,(zfix)y,id,clk);
17421 break;
17422
17423 case eeLANM:
17424 e = new eLanmola((zfix)x,(zfix)y,id,zc_max(1,zc_min(253,guysbuf[id&0xFFF].attributes[0])));
17425 break;
17426
17427 case eeGANON:
17428 e = new eGanon((zfix)x,(zfix)y,id,clk);
17429 break;
17430
17431 case eeFAIRY:
17432 e = new eItemFairy((zfix)x,(zfix)y,id+0x1000*clk,clk);
17433 break;
17434
17435 case eeFIRE:
17436
3/6
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
2 e = new eFire((zfix)x,(zfix)y,id,clk);
17437 2 break;
17438
17439 case eeOTHER:
17440 e = new eOther((zfix)x,(zfix)y,id,clk);
17441 break;
17442
17443
17444 case eeSCRIPT01:
17445 case eeSCRIPT02:
17446 case eeSCRIPT03:
17447 case eeSCRIPT04:
17448 case eeSCRIPT05:
17449 case eeSCRIPT06:
17450 case eeSCRIPT07:
17451 case eeSCRIPT08:
17452 case eeSCRIPT09:
17453 case eeSCRIPT10:
17454 case eeSCRIPT11:
17455 case eeSCRIPT12:
17456 case eeSCRIPT13:
17457 case eeSCRIPT14:
17458 case eeSCRIPT15:
17459 case eeSCRIPT16:
17460 case eeSCRIPT17:
17461 case eeSCRIPT18:
17462 case eeSCRIPT19:
17463 case eeSCRIPT20:
17464 {
17465 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
17466 {
17467 e = new eScript((zfix)x,(zfix)y,id,clk);
17468 break;
17469 }
17470 else return 0;
17471 }
17472
17473 case eeFFRIENDLY01:
17474 case eeFFRIENDLY02:
17475 case eeFFRIENDLY03:
17476 case eeFFRIENDLY04:
17477 case eeFFRIENDLY05:
17478 case eeFFRIENDLY06:
17479 case eeFFRIENDLY07:
17480 case eeFFRIENDLY08:
17481 case eeFFRIENDLY09:
17482 case eeFFRIENDLY10:
17483 {
17484 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
17485 {
17486 e = new eFriendly((zfix)x,(zfix)y,id,clk); break;
17487 }
17488 else return 0;
17489
17490 }
17491
17492 case eeSPINTILE:
17493 e = new eSpinTile((zfix)x,(zfix)y,id,clk);
17494 break;
17495
17496 // and these enemies use the misc10/misc2 value
17497 case eeROCK:
17498 {
17499 switch(guysbuf[id&0xFFF].attributes[9])
17500 {
17501 case 1:
17502 e = new eBoulder((zfix)x,(zfix)y,id,clk);
17503 break;
17504
17505 case 0:
17506 default:
17507 e = new eRock((zfix)x,(zfix)y,id,clk);
17508 break;
17509 }
17510
17511 break;
17512 }
17513
17514 case eeTRAP:
17515 {
17516 switch(guysbuf[id&0xFFF].attributes[1])
17517 {
17518 case 1:
17519 e = new eTrap2((zfix)x,(zfix)y,id,clk);
17520 break;
17521
17522 case 0:
17523 default:
17524 e = new eTrap((zfix)x,(zfix)y,id,clk);
17525 break;
17526 }
17527
17528 break;
17529 }
17530
17531 case eeDONGO:
17532 {
17533 switch(guysbuf[id&0xFFF].attributes[9])
17534 {
17535 case 1:
17536 e = new eDodongo2((zfix)x,(zfix)y,id,clk);
17537 break;
17538
17539 case 0:
17540 default:
17541 e = new eDodongo((zfix)x,(zfix)y,id,clk);
17542 break;
17543 }
17544
17545 break;
17546 }
17547
17548 case eeDIG:
17549 {
17550
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
4 switch(guysbuf[id&0xFFF].attributes[9])
17551 {
17552 case 1:
17553 e = new eLilDig((zfix)x,(zfix)y,id,clk);
17554 break;
17555
17556 4 case 0:
17557 default:
17558
3/6
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
4 e = new eBigDig((zfix)x,(zfix)y,id,clk);
17559 4 break;
17560 }
17561
17562 4 break;
17563 }
17564
17565 case eePATRA:
17566 {
17567 switch(guysbuf[id&0xFFF].attributes[9])
17568 {
17569 case 1:
17570 if (get_qr(qr_HARDCODED_BS_PATRA))
17571 {
17572 e = new ePatraBS((zfix)x,(zfix)y,id,clk);
17573 break;
17574 }
17575 [[fallthrough]];
17576 case 0:
17577 default:
17578 e = new ePatra((zfix)x,(zfix)y,id,clk);
17579 break;
17580 }
17581
17582 break;
17583 }
17584
17585 case eeGUY:
17586 {
17587 switch(guysbuf[id&0xFFF].attributes[9])
17588 {
17589 case 1:
17590 e = new eTrigger((zfix)x,(zfix)y,id,clk);
17591 break;
17592
17593 case 0:
17594 default:
17595 e = new eNPC((zfix)x,(zfix)y,id,clk);
17596 break;
17597 }
17598
17599 break;
17600 }
17601
17602 case eeNONE:
17603 if(guysbuf[id&0xFFF].attributes[9] ==1)
17604 {
17605 e = new eTrigger((zfix)x,(zfix)y,id,clk);
17606 break;
17607 break;
17608 }
17609 [[fallthrough]];
17610 default:
17611
17612 return 0;
17613 }
17614
17615 1997 ret++; // Made one enemy.
17616
17617
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 1990 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
1997 if(z && canfall(id))
17618 {
17619 7 e->z = (zfix)z;
17620 7 }
17621
17622
2/2
✓ Branch 0 taken 1990 times.
✓ Branch 1 taken 7 times.
1997 ((enemy*)e)->ceiling = (z && canfall(id));
17623 1997 ((enemy*)e)->parent_script_UID = parent_scriptUID;
17624
17625
17626
1/2
✓ Branch 0 taken 1997 times.
✗ Branch 1 not taken.
1997 if(!guys.add(e))
17627 {
17628 return 0;
17629 }
17630
17631 // add segments of segmented enemies
17632 1997 int32_t c=0;
17633
17634
2/6
✓ Branch 0 taken 1996 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1997 switch(guysbuf[id&0xFFF].family)
17635 {
17636 case eeMOLD:
17637 {
17638 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
17639 id &= 0xFFF;
17640
17641 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id].attributes[0])); i++)
17642 {
17643 //christ this is messy -DD
17644 int32_t segclk = -i*((int32_t)(8.0/(zslongToFix(guysbuf[id&0xFFF].step*100))));
17645
17646 if(!guys.add(new esMoldorm((zfix)x,(zfix)y,id+0x1000,segclk)))
17647 {
17648 al_trace("Moldorm segment %d could not be created!\n",i+1);
17649
17650 for(int32_t j=0; j<i+1; j++)
17651 guys.del(guys.Count()-1);
17652
17653 return 0;
17654 }
17655
17656 if(i>0)
17657 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
17658
17659 ret++;
17660 }
17661
17662 break;
17663 }
17664
17665 case eeLANM:
17666 {
17667 id &= 0xFFF;
17668 int32_t shft = guysbuf[id].attributes[1];
17669 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
17670
17671 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x1000,0)))
17672 {
17673 al_trace("Lanmola segment 1 could not be created!\n");
17674 guys.del(guys.Count()-1);
17675 return 0;
17676 }
17677
17678 ret++;
17679
17680 for(int32_t i=1; i<zc_max(1,zc_min(253,guysbuf[id&0xFFF].attributes[0])); i++)
17681 {
17682 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x2000,-(i<<shft))))
17683 {
17684 al_trace("Lanmola segment %d could not be created!\n",i+1);
17685
17686 for(int32_t j=0; j<i+1; j++)
17687 guys.del(guys.Count()-1);
17688
17689 return 0;
17690 }
17691
17692 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
17693 ret++;
17694 }
17695 }
17696 break;
17697
17698 case eeMANHAN:
17699 1 id &= 0xFFF;
17700
17701
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for(int32_t i=0; i<((!(guysbuf[id].attributes[1]))?4:8); i++)
17702 {
17703
4/8
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4 times.
✗ Branch 7 not taken.
4 if(!guys.add(new esManhandla((zfix)x,(zfix)y,id+0x1000,i)))
17704 {
17705 al_trace("Manhandla head %d could not be created!\n",i+1);
17706
17707 for(int32_t j=0; j<i+1; j++)
17708 {
17709 guys.del(guys.Count()-1);
17710 }
17711
17712 return 0;
17713 }
17714
17715 4 ret++;
17716 4 ((enemy*)guys.spr(guys.Count()-1))->frate=guysbuf[id].attributes[0];
17717 4 }
17718
17719 1 break;
17720
17721 case eeGLEEOK:
17722 {
17723 id &= 0xFFF;
17724
17725 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])); i++)
17726 {
17727 if(!guys.add(new esGleeok((zfix)x,(zfix)y,id+0x1000,c, e)))
17728 {
17729 al_trace("Gleeok head %d could not be created!\n",i+1);
17730
17731 for(int32_t j=0; j<i+1; j++)
17732 {
17733 guys.del(guys.Count()-1);
17734 }
17735
17736 return false;
17737 }
17738
17739 c-=guysbuf[id].attributes[3];
17740 ret++;
17741 }
17742 }
17743 break;
17744
17745
17746 case eePATRA:
17747 {
17748 id &= 0xFFF;
17749 int32_t outeyes = 0;
17750
17751 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].attributes[0]); i++)
17752 {
17753 if(!((guysbuf[id].attributes[9] &&get_qr(qr_HARDCODED_BS_PATRA))?guys.add(new esPatraBS((zfix)x,(zfix)y,id+0x1000,i,e)):guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e))))
17754 {
17755 al_trace("Patra outer eye %d could not be created!\n",i+1);
17756
17757 for(int32_t j=0; j<i+1; j++)
17758 guys.del(guys.Count()-1);
17759
17760 return 0;
17761 }
17762 else
17763 outeyes++;
17764
17765 ret++;
17766 }
17767
17768 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].attributes[1]); i++)
17769 {
17770 if(!guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e)))
17771 {
17772 al_trace("Patra inner eye %d could not be created!\n",i+1);
17773
17774 for(int32_t j=0; j<i+1+zc_min(254,outeyes); j++)
17775 guys.del(guys.Count()-1);
17776
17777 return 0;
17778 }
17779
17780 ret++;
17781 }
17782
17783 break;
17784 }
17785 }
17786
17787 1997 return ret;
17788 1997 }
17789
17790 // Returns number of enemies/segments created
17791 101448 int32_t addenemy(int32_t x,int32_t y,int32_t z,int32_t id,int32_t clk)
17792 {
17793 101448 int32_t realid = id&0xFFF;
17794
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101448 times.
101448 if( realid > MAXGUYS )
17795 {
17796 return 0;
17797 }
17798
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101448 times.
101448 if(id <= 0) return 0;
17799
17800 101448 int32_t ret = 0;
17801 101448 sprite *e=NULL;
17802
17803
28/31
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 50006 times.
✓ Branch 4 taken 3942 times.
✓ Branch 5 taken 5196 times.
✓ Branch 6 taken 1825 times.
✓ Branch 7 taken 2765 times.
✓ Branch 8 taken 461 times.
✓ Branch 9 taken 11717 times.
✓ Branch 10 taken 5311 times.
✓ Branch 11 taken 4429 times.
✓ Branch 12 taken 998 times.
✓ Branch 13 taken 126 times.
✓ Branch 14 taken 618 times.
✓ Branch 15 taken 149 times.
✓ Branch 16 taken 168 times.
✓ Branch 17 taken 93 times.
✓ Branch 18 taken 420 times.
✓ Branch 19 taken 13 times.
✓ Branch 20 taken 730 times.
✓ Branch 21 taken 757 times.
✓ Branch 22 taken 7330 times.
✓ Branch 23 taken 94 times.
✓ Branch 24 taken 384 times.
✓ Branch 25 taken 2432 times.
✓ Branch 26 taken 251 times.
✓ Branch 27 taken 403 times.
✓ Branch 28 taken 292 times.
✓ Branch 29 taken 5 times.
✓ Branch 30 taken 533 times.
101448 switch(guysbuf[id&0xFFF].family)
17804 {
17805 //Fixme: possible enemy memory leak. (minor)
17806 case eeWALK:
17807
3/6
✓ Branch 0 taken 50006 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 50006 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 50006 times.
✗ Branch 5 not taken.
50006 e = new eStalfos((zfix)x,(zfix)y,id,clk);
17808 50006 break;
17809
17810 case eeLEV:
17811
3/6
✓ Branch 0 taken 3942 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3942 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3942 times.
✗ Branch 5 not taken.
3942 e = new eLeever((zfix)x,(zfix)y,id,clk);
17812 3942 break;
17813
17814 case eeTEK:
17815
3/6
✓ Branch 0 taken 5196 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5196 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5196 times.
✗ Branch 5 not taken.
5196 e = new eTektite((zfix)x,(zfix)y,id,clk);
17816 5196 break;
17817
17818 case eePEAHAT:
17819
3/6
✓ Branch 0 taken 1825 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1825 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1825 times.
✗ Branch 5 not taken.
1825 e = new ePeahat((zfix)x,(zfix)y,id,clk);
17820 1825 break;
17821
17822 case eeZORA:
17823
3/6
✓ Branch 0 taken 2765 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2765 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2765 times.
✗ Branch 5 not taken.
2765 e = new eZora((zfix)x,(zfix)y,id,clk);
17824 2765 break;
17825
17826 case eeGHINI:
17827
3/6
✓ Branch 0 taken 461 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 461 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 461 times.
✗ Branch 5 not taken.
461 e = new eGhini((zfix)x,(zfix)y,id,clk);
17828 461 break;
17829
17830 case eeKEESE:
17831
3/6
✓ Branch 0 taken 11717 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11717 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11717 times.
✗ Branch 5 not taken.
11717 e = new eKeese((zfix)x,(zfix)y,id,clk);
17832 11717 break;
17833
17834 case eeWIZZ:
17835
3/6
✓ Branch 0 taken 5311 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5311 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5311 times.
✗ Branch 5 not taken.
5311 e = new eWizzrobe((zfix)x,(zfix)y,id,clk);
17836 5311 break;
17837
17838 case eePROJECTILE:
17839
3/6
✓ Branch 0 taken 4429 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4429 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4429 times.
✗ Branch 5 not taken.
4429 e = new eProjectile((zfix)x,(zfix)y,id,clk);
17840 4429 break;
17841
17842 case eeWALLM:
17843
3/6
✓ Branch 0 taken 998 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 998 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 998 times.
✗ Branch 5 not taken.
998 e = new eWallM((zfix)x,(zfix)y,id,clk);
17844 998 break;
17845
17846 case eeAQUA:
17847
3/6
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 126 times.
✗ Branch 5 not taken.
126 e = new eAquamentus((zfix)x,(zfix)y,id,clk);
17848 126 break;
17849
17850 case eeMOLD:
17851
6/12
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 618 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 618 times.
✓ Branch 6 taken 618 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 618 times.
✓ Branch 10 taken 618 times.
✗ Branch 11 not taken.
618 e = new eMoldorm((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])));
17852 618 break;
17853
17854 case eeMANHAN:
17855
3/6
✓ Branch 0 taken 149 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 149 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 149 times.
✗ Branch 5 not taken.
149 e = new eManhandla((zfix)x,(zfix)y,id,clk);
17856 149 break;
17857
17858 case eeGLEEOK:
17859
7/12
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 168 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 168 times.
✓ Branch 6 taken 152 times.
✓ Branch 7 taken 16 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 152 times.
✓ Branch 10 taken 168 times.
✗ Branch 11 not taken.
168 e = new eGleeok((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])));
17860 168 break;
17861
17862 case eeGHOMA:
17863
3/6
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 93 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 93 times.
✗ Branch 5 not taken.
93 e = new eGohma((zfix)x,(zfix)y,id,clk);
17864 93 break;
17865
17866 case eeLANM:
17867
6/12
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 420 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 420 times.
✓ Branch 6 taken 420 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 420 times.
✓ Branch 10 taken 420 times.
✗ Branch 11 not taken.
420 e = new eLanmola((zfix)x,(zfix)y,id,zc_max(1,zc_min(253,guysbuf[id&0xFFF].attributes[0])));
17868 420 break;
17869
17870 case eeGANON:
17871
3/6
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13 times.
✗ Branch 5 not taken.
13 e = new eGanon((zfix)x,(zfix)y,id,clk);
17872 13 break;
17873
17874 case eeFAIRY:
17875
3/6
✓ Branch 0 taken 730 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 730 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 730 times.
✗ Branch 5 not taken.
730 e = new eItemFairy((zfix)x,(zfix)y,id+0x1000*clk,clk);
17876 730 break;
17877
17878 case eeFIRE:
17879
3/6
✓ Branch 0 taken 757 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 757 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 757 times.
✗ Branch 5 not taken.
757 e = new eFire((zfix)x,(zfix)y,id,clk);
17880 757 break;
17881
17882 case eeOTHER:
17883
3/6
✓ Branch 0 taken 7330 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7330 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7330 times.
✗ Branch 5 not taken.
7330 e = new eOther((zfix)x,(zfix)y,id,clk);
17884 7330 break;
17885
17886
17887 case eeSCRIPT01:
17888 case eeSCRIPT02:
17889 case eeSCRIPT03:
17890 case eeSCRIPT04:
17891 case eeSCRIPT05:
17892 case eeSCRIPT06:
17893 case eeSCRIPT07:
17894 case eeSCRIPT08:
17895 case eeSCRIPT09:
17896 case eeSCRIPT10:
17897 case eeSCRIPT11:
17898 case eeSCRIPT12:
17899 case eeSCRIPT13:
17900 case eeSCRIPT14:
17901 case eeSCRIPT15:
17902 case eeSCRIPT16:
17903 case eeSCRIPT17:
17904 case eeSCRIPT18:
17905 case eeSCRIPT19:
17906 case eeSCRIPT20:
17907 {
17908 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
17909 {
17910 e = new eScript((zfix)x,(zfix)y,id,clk);
17911 break;
17912 }
17913 else return 0;
17914 }
17915
17916 case eeFFRIENDLY01:
17917 case eeFFRIENDLY02:
17918 case eeFFRIENDLY03:
17919 case eeFFRIENDLY04:
17920 case eeFFRIENDLY05:
17921 case eeFFRIENDLY06:
17922 case eeFFRIENDLY07:
17923 case eeFFRIENDLY08:
17924 case eeFFRIENDLY09:
17925 case eeFFRIENDLY10:
17926 {
17927 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
17928 {
17929 e = new eFriendly((zfix)x,(zfix)y,id,clk); break;
17930 }
17931 else return 0;
17932
17933 }
17934
17935 case eeSPINTILE:
17936
3/6
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 94 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 94 times.
✗ Branch 5 not taken.
94 e = new eSpinTile((zfix)x,(zfix)y,id,clk);
17937 94 break;
17938
17939 // and these enemies use the misc10/misc2 value
17940 case eeROCK:
17941 {
17942
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✓ Branch 2 taken 354 times.
384 switch(guysbuf[id&0xFFF].attributes[9])
17943 {
17944 case 1:
17945
3/6
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 30 times.
✗ Branch 5 not taken.
30 e = new eBoulder((zfix)x,(zfix)y,id,clk);
17946 30 break;
17947
17948 354 case 0:
17949 default:
17950
3/6
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 354 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 354 times.
✗ Branch 5 not taken.
354 e = new eRock((zfix)x,(zfix)y,id,clk);
17951 354 break;
17952 }
17953
17954 384 break;
17955 }
17956
17957 case eeTRAP:
17958 {
17959
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
✓ Branch 2 taken 1600 times.
2432 switch(guysbuf[id&0xFFF].attributes[1])
17960 {
17961 case 1:
17962
3/6
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 832 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 832 times.
✗ Branch 5 not taken.
832 e = new eTrap2((zfix)x,(zfix)y,id,clk);
17963 832 break;
17964
17965 1600 case 0:
17966 default:
17967
3/6
✓ Branch 0 taken 1600 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1600 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1600 times.
✗ Branch 5 not taken.
1600 e = new eTrap((zfix)x,(zfix)y,id,clk);
17968 1600 break;
17969 }
17970
17971 2432 break;
17972 }
17973
17974 case eeDONGO:
17975 {
17976
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 203 times.
251 switch(guysbuf[id&0xFFF].attributes[9])
17977 {
17978 case 1:
17979
3/6
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 48 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 48 times.
✗ Branch 5 not taken.
48 e = new eDodongo2((zfix)x,(zfix)y,id,clk);
17980 48 break;
17981
17982 203 case 0:
17983 default:
17984
3/6
✓ Branch 0 taken 203 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 203 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 203 times.
✗ Branch 5 not taken.
203 e = new eDodongo((zfix)x,(zfix)y,id,clk);
17985 203 break;
17986 }
17987
17988 251 break;
17989 }
17990
17991 case eeDIG:
17992 {
17993
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 327 times.
✓ Branch 2 taken 76 times.
403 switch(guysbuf[id&0xFFF].attributes[9])
17994 {
17995 case 1:
17996
3/6
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 327 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 327 times.
✗ Branch 5 not taken.
327 e = new eLilDig((zfix)x,(zfix)y,id,clk);
17997 327 break;
17998
17999 76 case 0:
18000 default:
18001
3/6
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 76 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 76 times.
✗ Branch 5 not taken.
76 e = new eBigDig((zfix)x,(zfix)y,id,clk);
18002 76 break;
18003 }
18004
18005 403 break;
18006 }
18007
18008 case eePATRA:
18009 {
18010
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✓ Branch 2 taken 102 times.
292 switch(guysbuf[id&0xFFF].attributes[9])
18011 {
18012 case 1:
18013
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if (get_qr(qr_HARDCODED_BS_PATRA))
18014 {
18015
3/6
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 102 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 102 times.
✗ Branch 5 not taken.
102 e = new ePatraBS((zfix)x,(zfix)y,id,clk);
18016 102 break;
18017 }
18018 [[fallthrough]];
18019 190 case 0:
18020 default:
18021
3/6
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 190 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 190 times.
✗ Branch 5 not taken.
190 e = new ePatra((zfix)x,(zfix)y,id,clk);
18022 190 break;
18023 }
18024
18025 292 break;
18026 }
18027
18028 case eeGUY:
18029 {
18030
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
5 switch(guysbuf[id&0xFFF].attributes[9])
18031 {
18032 case 1:
18033 e = new eTrigger((zfix)x,(zfix)y,id,clk);
18034 break;
18035
18036 5 case 0:
18037 default:
18038
3/6
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
5 e = new eNPC((zfix)x,(zfix)y,id,clk);
18039 5 break;
18040 }
18041
18042 5 break;
18043 }
18044
18045 case eeNONE:
18046
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 if(guysbuf[id&0xFFF].attributes[9] ==1)
18047 {
18048
3/6
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 533 times.
✗ Branch 5 not taken.
533 e = new eTrigger((zfix)x,(zfix)y,id,clk);
18049 533 break;
18050 break;
18051 }
18052 [[fallthrough]];
18053 default:
18054
18055 return 0;
18056 }
18057
18058 101448 ret++; // Made one enemy.
18059
18060
4/4
✓ Branch 0 taken 131 times.
✓ Branch 1 taken 101317 times.
✓ Branch 2 taken 25 times.
✓ Branch 3 taken 106 times.
101448 if(z && canfall(id))
18061 {
18062 106 e->z = (zfix)z;
18063 106 }
18064
18065
2/2
✓ Branch 0 taken 101317 times.
✓ Branch 1 taken 131 times.
101448 ((enemy*)e)->ceiling = (z && canfall(id));
18066
18067
1/2
✓ Branch 0 taken 101448 times.
✗ Branch 1 not taken.
101448 if(!guys.add(e))
18068 {
18069 return 0;
18070 }
18071
18072 // add segments of segmented enemies
18073 101448 int32_t c=0;
18074
18075
6/6
✓ Branch 0 taken 99801 times.
✓ Branch 1 taken 618 times.
✓ Branch 2 taken 420 times.
✓ Branch 3 taken 149 times.
✓ Branch 4 taken 168 times.
✓ Branch 5 taken 292 times.
101448 switch(guysbuf[id&0xFFF].family)
18076 {
18077 case eeMOLD:
18078 {
18079 618 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
18080 618 id &= 0xFFF;
18081
18082
5/8
✗ Branch 0 not taken.
✓ Branch 1 taken 3768 times.
✓ Branch 2 taken 3768 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3768 times.
✓ Branch 6 taken 3150 times.
✓ Branch 7 taken 618 times.
3768 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id].attributes[0])); i++)
18083 {
18084 //christ this is messy -DD
18085 3150 int32_t segclk = -i*((int32_t)(8.0/(zslongToFix(guysbuf[id&0xFFF].step*100))));
18086
18087
4/8
✓ Branch 0 taken 3150 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3150 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3150 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3150 times.
✗ Branch 7 not taken.
3150 if(!guys.add(new esMoldorm((zfix)x,(zfix)y,id+0x1000,segclk)))
18088 {
18089 al_trace("Moldorm segment %d could not be created!\n",i+1);
18090
18091 for(int32_t j=0; j<i+1; j++)
18092 guys.del(guys.Count()-1);
18093
18094 return 0;
18095 }
18096
18097
2/2
✓ Branch 0 taken 618 times.
✓ Branch 1 taken 2532 times.
3150 if(i>0)
18098 2532 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
18099
18100 3150 ret++;
18101 3150 }
18102
18103 618 break;
18104 }
18105
18106 case eeLANM:
18107 {
18108 420 id &= 0xFFF;
18109 420 int32_t shft = guysbuf[id].attributes[1];
18110 420 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
18111
18112
4/8
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 420 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 420 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 420 times.
✗ Branch 7 not taken.
420 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x1000,0)))
18113 {
18114 al_trace("Lanmola segment 1 could not be created!\n");
18115 guys.del(guys.Count()-1);
18116 return 0;
18117 }
18118
18119 420 ret++;
18120
18121
5/8
✗ Branch 0 not taken.
✓ Branch 1 taken 2267 times.
✓ Branch 2 taken 2267 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2267 times.
✓ Branch 6 taken 1847 times.
✓ Branch 7 taken 420 times.
2267 for(int32_t i=1; i<zc_max(1,zc_min(253,guysbuf[id&0xFFF].attributes[0])); i++)
18122 {
18123
4/8
✓ Branch 0 taken 1847 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1847 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1847 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1847 times.
✗ Branch 7 not taken.
1847 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x2000,-(i<<shft))))
18124 {
18125 al_trace("Lanmola segment %d could not be created!\n",i+1);
18126
18127 for(int32_t j=0; j<i+1; j++)
18128 guys.del(guys.Count()-1);
18129
18130 return 0;
18131 }
18132
18133 1847 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
18134 1847 ret++;
18135 1847 }
18136 }
18137 420 break;
18138
18139 case eeMANHAN:
18140 149 id &= 0xFFF;
18141
18142
2/2
✓ Branch 0 taken 688 times.
✓ Branch 1 taken 149 times.
837 for(int32_t i=0; i<((!(guysbuf[id].attributes[1]))?4:8); i++)
18143 {
18144
4/8
✓ Branch 0 taken 688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 688 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 688 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 688 times.
✗ Branch 7 not taken.
688 if(!guys.add(new esManhandla((zfix)x,(zfix)y,id+0x1000,i)))
18145 {
18146 al_trace("Manhandla head %d could not be created!\n",i+1);
18147
18148 for(int32_t j=0; j<i+1; j++)
18149 {
18150 guys.del(guys.Count()-1);
18151 }
18152
18153 return 0;
18154 }
18155
18156 688 ret++;
18157 688 ((enemy*)guys.spr(guys.Count()-1))->frate=guysbuf[id].attributes[0];
18158 688 }
18159
18160 149 break;
18161
18162 case eeGLEEOK:
18163 {
18164 168 id &= 0xFFF;
18165 168 eGleeok* parent = (eGleeok*)e;
18166
18167
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 701 times.
✓ Branch 2 taken 669 times.
✓ Branch 3 taken 32 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 669 times.
✓ Branch 6 taken 533 times.
✓ Branch 7 taken 168 times.
701 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])); i++)
18168 {
18169
3/6
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 533 times.
✗ Branch 5 not taken.
533 esGleeok* head = new esGleeok((zfix)x,(zfix)y,id+0x1000,c, e);
18170
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 if(!guys.add(head))
18171 {
18172 al_trace("Gleeok head %d could not be created!\n",i+1);
18173
18174 for(int32_t j=0; j<i+1; j++)
18175 {
18176 guys.del(guys.Count()-1);
18177 }
18178
18179 return false;
18180 }
18181
18182 533 head->necktile=parent->necktile;
18183 533 head->dummy_int[1]=parent->necktile;
18184
2/2
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 112 times.
533 if(get_qr(qr_NEWENEMYTILES))
18185 {
18186 421 head->dummy_int[2]=parent->o_tile+parent->dmisc8; //connected head tile
18187 421 head->dummy_int[3]=parent->o_tile+parent->dmisc9; //flying head tile
18188 421 }
18189 else
18190 {
18191 112 head->dummy_int[2]=parent->necktile+1; //connected head tile
18192 112 head->dummy_int[3]=parent->necktile+2; //flying head tile
18193 }
18194 533 head->tile = head->dummy_int[2];
18195
18196 533 c-=guysbuf[id].attributes[3];
18197 533 ret++;
18198 533 }
18199 }
18200 168 break;
18201
18202
18203 case eePATRA:
18204 {
18205 292 id &= 0xFFF;
18206 292 int32_t outeyes = 0;
18207
18208
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2248 times.
✓ Branch 2 taken 1956 times.
✓ Branch 3 taken 292 times.
2248 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].attributes[0]); i++)
18209 {
18210
10/22
✓ Branch 0 taken 612 times.
✓ Branch 1 taken 1344 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 612 times.
✓ Branch 4 taken 612 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 612 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 612 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1344 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1344 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1344 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 1344 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
1956 if(!((guysbuf[id].attributes[9] &&get_qr(qr_HARDCODED_BS_PATRA))?guys.add(new esPatraBS((zfix)x,(zfix)y,id+0x1000,i,e)):guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e))))
18211 {
18212 al_trace("Patra outer eye %d could not be created!\n",i+1);
18213
18214 for(int32_t j=0; j<i+1; j++)
18215 guys.del(guys.Count()-1);
18216
18217 return 0;
18218 }
18219 else
18220 1956 outeyes++;
18221
18222 1956 ret++;
18223 1956 }
18224
18225
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 604 times.
✓ Branch 2 taken 312 times.
✓ Branch 3 taken 292 times.
604 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].attributes[1]); i++)
18226 {
18227
4/8
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 312 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 312 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 312 times.
✗ Branch 7 not taken.
312 if(!guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e)))
18228 {
18229 al_trace("Patra inner eye %d could not be created!\n",i+1);
18230
18231 for(int32_t j=0; j<i+1+zc_min(254,outeyes); j++)
18232 guys.del(guys.Count()-1);
18233
18234 return 0;
18235 }
18236
18237 312 ret++;
18238 312 }
18239
18240 292 break;
18241 }
18242 }
18243
18244 101448 return ret;
18245 101448 }
18246
18247 1854987 bool isjumper(int32_t id)
18248 {
18249
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1854987 times.
1854987 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
18250 {
18251 return false;
18252 }
18253
3/3
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 1752784 times.
✓ Branch 2 taken 102194 times.
1854987 switch(guysbuf[id&0xFFF].family)
18254 {
18255 case eeROCK:
18256 case eeTEK:
18257 9 return true;
18258
18259 case eeWALK:
18260
3/4
✓ Branch 0 taken 102194 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12265 times.
✓ Branch 3 taken 89929 times.
102194 if(guysbuf[id&0xFFF].attributes[8] == e9tVIRE || guysbuf[id & 0xFFF].attributes[8] == e9tPOLSVOICE) return true;
18261 89929 }
18262
18263 1842713 return false;
18264 1854987 }
18265
18266
18267 291829 bool isfixedtogrid(int32_t id)
18268 {
18269
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 291829 times.
291829 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
18270 {
18271 return false;
18272 }
18273
1/2
✓ Branch 0 taken 291829 times.
✗ Branch 1 not taken.
291829 switch(guysbuf[id&0xFFF].family)
18274 {
18275 case eeWALK:
18276 case eeLEV:
18277 case eeZORA:
18278 case eeDONGO:
18279 case eeGANON:
18280 case eeROCK:
18281 case eeGLEEOK:
18282 case eeAQUA:
18283 case eeLANM:
18284 return true;
18285 }
18286
18287 291829 return false;
18288 291829 }
18289
18290 // Can't fall, can have Z value.
18291 51793523 bool isflier(int32_t id)
18292 {
18293
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51793523 times.
51793523 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
18294 {
18295 return false;
18296 }
18297
2/2
✓ Branch 0 taken 45365666 times.
✓ Branch 1 taken 6427857 times.
51793523 switch(guysbuf[id&0xFFF].family) //id&0x0FFF)
18298 {
18299 case eePEAHAT:
18300 case eeKEESE:
18301 case eePATRA:
18302 case eeFAIRY:
18303 case eeGHINI:
18304
18305 // Could theoretically have their Z set by a script
18306 case eeFIRE:
18307 6427857 return true;
18308 break;
18309 }
18310
18311 45365666 return false;
18312 51793523 }
18313
18314 // Can't have Z position
18315 3707124 bool never_in_air(int32_t id)
18316 {
18317
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3707124 times.
3707124 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
18318 {
18319 return false;
18320 }
18321
2/2
✓ Branch 0 taken 3697574 times.
✓ Branch 1 taken 9550 times.
3707124 switch(guysbuf[id&0xFFF].family)
18322 {
18323 case eeMANHAN:
18324 case eeMOLD:
18325 case eeLANM:
18326 case eeGLEEOK:
18327 case eeZORA:
18328 case eeLEV:
18329 case eeAQUA:
18330 case eeROCK:
18331 case eeGANON:
18332 case eeTRAP:
18333 case eePROJECTILE:
18334 case eeSPINTILE:
18335 9550 return true;
18336 }
18337
18338 3697574 return false;
18339 3707124 }
18340
18341 2015748 bool canfall(int32_t id)
18342 {
18343
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2015748 times.
2015748 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
18344 {
18345 return false;
18346 }
18347
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 2015708 times.
✓ Branch 2 taken 40 times.
2015748 switch(guysbuf[id&0xFFF].family)
18348 {
18349 case eeGUY:
18350 {
18351
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if(id < eOCTO1S)
18352 40 return false;
18353
18354 switch(guysbuf[id&0xFFF].attributes[9])
18355 {
18356 case 1:
18357 case 2:
18358 return true;
18359
18360 case 0:
18361 case 3:
18362 default:
18363 return false;
18364 }
18365
18366 case eeGHOMA:
18367 case eeDIG:
18368 return false;
18369 }
18370 }
18371
18372
18373
4/4
✓ Branch 0 taken 2007272 times.
✓ Branch 1 taken 8436 times.
✓ Branch 2 taken 152285 times.
✓ Branch 3 taken 1854987 times.
2015708 return !never_in_air(id) && !isflier(id) && !isjumper(id);
18374 2015748 }
18375
18376 73558520 bool enemy::enemycanfall(int32_t id, bool checkgrav)
18377 {
18378
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 73558520 times.
73558520 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
18379 {
18380 return false;
18381 }
18382 //Z_scripterrlog("canfall family is %d:\n", family);
18383 //Z_scripterrlog("canfall gravity is %s:\n", moveflags & move_obeys_grav ? "true" : "false");
18384 //if ( family == eeFIRE && id >= eSTART )
18385 //{
18386 // Z_scripterrlog("eeFire\n");
18387 // return moveflags & move_obeys_grav; //'Other' enemy class, used by scripts. -Z
18388 //}
18389
18390 //In ZQ, eeFIRE is Other(floating) and eeOTHER is 'other'.
18391
18392
3/3
✓ Branch 0 taken 428935 times.
✓ Branch 1 taken 71055322 times.
✓ Branch 2 taken 2074263 times.
73558520 switch(guysbuf[id&0xFFF].family)
18393 {
18394 case eeGUY:
18395 {
18396
1/2
✓ Branch 0 taken 2074263 times.
✗ Branch 1 not taken.
2074263 if(id < eOCTO1S) //screen guys and fires that aren't real enemies, and never fall
18397 2074263 return false;
18398
18399 switch(guysbuf[id&0xFFF].attributes[9]) //I'm unsure what these specify off-hand. Needs better comments. -Z
18400 {
18401 case 1:
18402 case 2:
18403 return true;
18404
18405 case 0:
18406 case 3:
18407 default:
18408 return false;
18409 }
18410
18411 case eeGHOMA:
18412 case eeDIG:
18413 428935 return false;
18414 }
18415 }
18416
18417
2/2
✓ Branch 0 taken 38950556 times.
✓ Branch 1 taken 32104766 times.
71055322 if(!checkgrav) return true;
18418 38950556 return (moveflags & move_obeys_grav);
18419
18420 // if ( isflier(id) || isjumper(id) || never_in_air(id) )
18421 // {
18422 // if ( moveflags & move_obeys_grav ) return true;
18423 // else return false;
18424 // }
18425 // else
18426 // {
18427 // return (moveflags & move_obeys_grav);
18428 // }
18429 //return !never_in_air(id) && !isflier(id) && !isjumper(id);
18430 73558520 }
18431
18432 1269 void addfires()
18433 {
18434
2/2
✓ Branch 0 taken 814 times.
✓ Branch 1 taken 455 times.
1269 if(!get_qr(qr_NOGUYFIRES))
18435 {
18436 455 int32_t bs = get_qr(qr_BSZELDA);
18437 455 addguy(bs? 64: 72,64,gFIRE,-17,false,nullptr);
18438 455 addguy(bs?176:168,64,gFIRE,-18,false,nullptr);
18439 455 }
18440 1269 }
18441
18442 35222 void loadguys()
18443 {
18444
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35222 times.
35222 if(loaded_guys)
18445 return;
18446
18447 35222 loaded_guys=true;
18448
18449 35222 byte Guy=0;
18450 // When in caves/item rooms, use mSPECIALITEM and ipONETIME2
18451 // Else use mITEM and ipONETIME
18452 35222 int32_t mf = (currscr>=128) ? mSPECIALITEM : mITEM;
18453 35222 int32_t onetime = (currscr>=128) ? ipONETIME2 : ipONETIME;
18454
18455 35222 repaircharge=0;
18456 35222 adjustmagic=false;
18457 35222 learnslash=false;
18458
18459
2/2
✓ Branch 0 taken 105666 times.
✓ Branch 1 taken 35222 times.
140888 for(int32_t i=0; i<3; i++)
18460 {
18461 105666 prices[i]=0;
18462 105666 }
18463
18464 35222 hasitem=0;
18465
18466 35222 mapscr* guyscr = tmpscr;
18467
4/4
✓ Branch 0 taken 904 times.
✓ Branch 1 taken 34318 times.
✓ Branch 2 taken 475 times.
✓ Branch 3 taken 429 times.
35222 if(currscr>=128 && DMaps[currdmap].flags&dmfGUYCAVES)
18468 {
18469
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 429 times.
429 if(DMaps[currdmap].flags&dmfCAVES)
18470 {
18471 429 Guy=tmpscr[1].guy;
18472 429 guyscr = tmpscr+1;
18473 429 }
18474 429 }
18475 else
18476 {
18477 34793 Guy=tmpscr->guy;
18478
18479
4/4
✓ Branch 0 taken 34318 times.
✓ Branch 1 taken 475 times.
✓ Branch 2 taken 24145 times.
✓ Branch 3 taken 10173 times.
34793 if(currscr < 0x80 && (DMaps[currdmap].flags&dmfVIEWMAP))
18480 10173 game->maps[(currmap*MAPSCRSNORMAL)+currscr] |= mVISITED; // mark as visited
18481 }
18482
18483 35222 bool oldguy = get_qr(qr_OLD_GUY_HANDLING);
18484 // The Guy appears if 'Hero is in cave' equals 'Guy is in cave'.
18485
4/4
✓ Branch 0 taken 3847 times.
✓ Branch 1 taken 31375 times.
✓ Branch 2 taken 2538 times.
✓ Branch 3 taken 1309 times.
35222 if(Guy && ((currscr>=128) == !!(DMaps[currdmap].flags&dmfGUYCAVES)))
18486 {
18487
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 1298 times.
1309 if(tmpscr->room==rZELDA)
18488 {
18489 11 addguy(120,72,Guy,-15,true,guyscr);
18490 11 guys.spr(0)->hxofs=1000;
18491 11 addenemy(128,96,eFIRE,-15);
18492 11 addenemy(112,96,eFIRE,-15);
18493 11 addenemy(96,120,eFIRE,-15);
18494 11 addenemy(144,120,eFIRE,-15);
18495 11 return;
18496 }
18497
18498
2/2
✓ Branch 0 taken 1294 times.
✓ Branch 1 taken 4 times.
2592 bool ffire = oldguy
18499
2/2
✓ Branch 0 taken 1269 times.
✓ Branch 1 taken 25 times.
1294 ? (Guy!=gFAIRY || !get_qr(qr_NOFAIRYGUYFIRES))
18500 4 : (guyscr->roomflags&RFL_GUYFIRES);
18501
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 1269 times.
1298 if(ffire)
18502 1269 addfires();
18503
18504
2/2
✓ Branch 0 taken 875 times.
✓ Branch 1 taken 423 times.
1298 if(currscr>=128)
18505
3/4
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 410 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
436 if(getmapflag() && !(tmpscr->flags9&fBELOWRETURN))
18506 13 Guy=0;
18507
18508
4/6
✓ Branch 0 taken 167 times.
✓ Branch 1 taken 1085 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 45 times.
1298 switch(tmpscr->room)
18509 {
18510 case rSP_ITEM:
18511 case rGRUMBLE:
18512 case rBOMBS:
18513 case rARROWS:
18514 case rSWINDLE:
18515 case rMUPGRADE:
18516 case rLEARNSLASH:
18517 case rTAKEONE:
18518
8/8
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 55 times.
✓ Branch 3 taken 49 times.
✓ Branch 4 taken 63 times.
✓ Branch 5 taken 49 times.
✓ Branch 6 taken 21 times.
✓ Branch 7 taken 42 times.
167 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag((currscr < 128) ? mITEM : mSPECIALITEM)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag() && !(tmpscr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18519 55 Guy=0;
18520
18521 167 break;
18522
18523 case rREPAIR:
18524 if (get_qr(qr_OLD_DOORREPAIR)) break;
18525 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag((currscr < 128) ? mITEM : mSPECIALITEM)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag() && !(tmpscr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18526 Guy=0;
18527
18528 break;
18529 case rRP_HC:
18530 if (get_qr(qr_OLD_POTION_OR_HC)) break;
18531 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag((currscr < 128) ? mITEM : mSPECIALITEM)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag() && !(tmpscr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18532 Guy=0;
18533
18534 break;
18535 case rMONEY:
18536
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (get_qr(qr_OLD_SECRETMONEY)) break;
18537 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag((currscr < 128) ? mITEM : mSPECIALITEM)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag() && !(tmpscr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18538 Guy=0;
18539
18540 break;
18541
18542 case rTRIFORCE:
18543 {
18544 45 int32_t tc = TriforceCount();
18545
18546
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 34 times.
45 if(get_qr(qr_4TRI))
18547 {
18548
4/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 1 times.
11 if((get_qr(qr_3TRI) && tc>=3) || tc>=4)
18549 10 Guy=0;
18550 9 }
18551 else
18552 {
18553
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 34 times.
✓ Branch 2 taken 33 times.
✓ Branch 3 taken 1 times.
34 if((get_qr(qr_3TRI) && tc>=6) || tc>=8)
18554 33 Guy=0;
18555 }
18556 }
18557 43 break;
18558 }
18559
18560
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 1189 times.
1296 if(Guy)
18561 {
18562
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 1160 times.
1189 if(ffire)
18563 1160 blockpath=true;
18564
18565
2/2
✓ Branch 0 taken 410 times.
✓ Branch 1 taken 779 times.
1189 if(currscr<128)
18566 779 sfx(WAV_SCALE);
18567
18568
4/4
✓ Branch 0 taken 461 times.
✓ Branch 1 taken 728 times.
✓ Branch 2 taken 106 times.
✓ Branch 3 taken 355 times.
1189 addguy(120,64,Guy, (dlevel||BSZ)?-15:startguy[zc_oldrand()&7], true,guyscr);
18569 1189 Hero.Freeze();
18570 1189 }
18571 1296 }
18572
5/6
✓ Branch 0 taken 32124 times.
✓ Branch 1 taken 1789 times.
✓ Branch 2 taken 71 times.
✓ Branch 3 taken 32053 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1789 times.
33913 else if(oldguy ? Guy==gFAIRY : (Guy && (guyscr->roomflags&RFL_ALWAYS_GUY))) // The only Guy that somewhat ignores the "Guys In Caves Only" DMap flag
18573 {
18574 71 sfx(WAV_SCALE);
18575 71 addguy(120,62,Guy,-14,false,guyscr);
18576 71 }
18577
18578 35209 loaditem();
18579
18580 // Collecting a rupee in a '10 Rupees' screen sets the mITEM screen state if
18581 // it doesn't appear in a Cave/Item Cellar, and the mSPECIALITEM screen state if it does.
18582
4/4
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 35190 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 15 times.
35209 if(tmpscr->room==r10RUPIES && !getmapflag(mf))
18583 {
18584 //setmapflag();
18585
2/2
✓ Branch 0 taken 150 times.
✓ Branch 1 taken 15 times.
165 for(int32_t i=0; i<10; i++)
18586 150 additem(ten_rupies_x[i],ten_rupies_y[i],0,ipBIGRANGE+onetime,-14);
18587 15 }
18588 35220 }
18589
18590 35228 void loaditem()
18591 {
18592 35228 byte Item = 0;
18593
18594
2/2
✓ Branch 0 taken 34324 times.
✓ Branch 1 taken 904 times.
35228 if(currscr<128)
18595 {
18596 34324 Item=tmpscr->item;
18597
18598
4/4
✓ Branch 0 taken 1579 times.
✓ Branch 1 taken 32745 times.
✓ Branch 2 taken 31299 times.
✓ Branch 3 taken 3025 times.
34324 if((!getmapflag(mITEM) || (tmpscr->flags9&fITEMRETURN)) && (tmpscr->hasitem != 0))
18599 {
18600
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 2966 times.
3025 if(tmpscr->flags8&fSECRETITEM)
18601 59 hasitem=8;
18602
2/2
✓ Branch 0 taken 1157 times.
✓ Branch 1 taken 1809 times.
2966 else if(tmpscr->flags&fITEM)
18603 1157 hasitem=1;
18604
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 1745 times.
1809 else if(tmpscr->enemyflags&efCARRYITEM)
18605 64 hasitem=4; // Will be set to 2 by roaming_item
18606 else
18607
2/4
✓ Branch 0 taken 1745 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1745 times.
✗ Branch 3 not taken.
3490 items.add(new item((zfix)tmpscr->itemx,
18608
6/12
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 1730 times.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 15 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 1745 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1745 times.
✗ Branch 11 not taken.
1745 (tmpscr->flags7&fITEMFALLS && isSideViewGravity()) ? (zfix)-170 : (zfix)tmpscr->itemy+(get_qr(qr_NOITEMOFFSET)?0:1),
18609
6/10
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 1730 times.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 15 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1730 times.
✗ Branch 9 not taken.
1745 (tmpscr->flags7&fITEMFALLS && !(isSideViewGravity())) ? (zfix)170 : (zfix)0,
18610
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 1640 times.
1745 Item,ipONETIME|ipBIGRANGE|((itemsbuf[Item].family==itype_triforcepiece ||
18611 1745 (tmpscr->flags3&fHOLDITEM)) ? ipHOLDUP : 0) | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0),0));
18612 3025 }
18613 34324 }
18614
2/2
✓ Branch 0 taken 429 times.
✓ Branch 1 taken 475 times.
904 else if(!(DMaps[currdmap].flags&dmfCAVES))
18615 {
18616
4/6
✓ Branch 0 taken 475 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 469 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 16 times.
491 if((!getmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr[1].flags9&fBELOWRETURN)) && tmpscr[1].room==rSP_ITEM
18617
4/4
✓ Branch 0 taken 163 times.
✓ Branch 1 taken 312 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 147 times.
475 && (currscr==128 || !get_qr(qr_ITEMSINPASSAGEWAYS)))
18618 {
18619 163 Item=tmpscr[1].catchall;
18620
18621
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 162 times.
163 if(Item)
18622
2/4
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 162 times.
✗ Branch 3 not taken.
324 items.add(new item((zfix)tmpscr->itemx,
18623
3/12
✗ Branch 0 not taken.
✓ Branch 1 taken 162 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 162 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 162 times.
✗ Branch 11 not taken.
162 (tmpscr->flags7&fITEMFALLS && isSideViewGravity()) ? (zfix)-170 : (zfix)tmpscr->itemy+(get_qr(qr_NOITEMOFFSET)?0:1),
18624
2/10
✗ Branch 0 not taken.
✓ Branch 1 taken 162 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 162 times.
✗ Branch 9 not taken.
162 (tmpscr->flags7&fITEMFALLS && !(isSideViewGravity())) ? (zfix)170 : (zfix)0,
18625 162 Item,ipONETIME2|ipBIGRANGE|ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0),0));
18626 163 }
18627 475 }
18628 35228 }
18629
18630 957 void never_return(int32_t index)
18631 {
18632
2/2
✓ Branch 0 taken 766 times.
✓ Branch 1 taken 191 times.
957 if(!get_qr(qr_KILLALL))
18633 191 goto doit;
18634
18635
2/2
✓ Branch 0 taken 2292 times.
✓ Branch 1 taken 329 times.
2621 for(int32_t i=0; i<guys.Count(); i++)
18636
4/4
✓ Branch 0 taken 980 times.
✓ Branch 1 taken 1312 times.
✓ Branch 2 taken 543 times.
✓ Branch 3 taken 437 times.
2292 if(((((enemy*)guys.spr(i))->d->flags)&guy_never_return) && i!=index)
18637 {
18638 437 goto dontdoit;
18639 329 }
18640
18641 doit:
18642 520 setmapflag(mNEVERRET);
18643 dontdoit:
18644 957 return;
18645 }
18646
18647 63436 bool slowguy(int32_t id)
18648 {
18649
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63436 times.
63436 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
18650 {
18651 return false;
18652 }
18653 //return (guysbuf[id].step<100);
18654
2/2
✓ Branch 0 taken 53852 times.
✓ Branch 1 taken 9584 times.
63436 switch(id)
18655 {
18656 case eOCTO1S:
18657 case eOCTO2S:
18658 case eOCTO1F:
18659 case eOCTO2F:
18660 case eLEV1:
18661 case eLEV2:
18662 case eROCK:
18663 case eBOULDER:
18664 9584 return true;
18665 }
18666
18667 53852 return false;
18668 63436 }
18669
18670 82772 bool ok2add(int32_t id)
18671 {
18672
2/4
✓ Branch 0 taken 82772 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 82772 times.
82772 if( ((unsigned)(id&0xFFF)) > MAXGUYS || id <= 0)
18673 {
18674 return false;
18675 }
18676
4/4
✓ Branch 0 taken 829 times.
✓ Branch 1 taken 81943 times.
✓ Branch 2 taken 464 times.
✓ Branch 3 taken 365 times.
82772 if(getmapflag(mNEVERRET) && (guysbuf[id].flags & guy_never_return))
18677 464 return false;
18678
18679
4/4
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 81667 times.
✓ Branch 2 taken 376 times.
✓ Branch 3 taken 201 times.
82308 switch(guysbuf[id].family)
18680 {
18681 // I added a special case for shooters because having traps on the same screen
18682 // was preventing them from spawning due to TMPNORET. This means they will
18683 // never stay dead, though, so it may not be the best solution. - Saf
18684 case eePROJECTILE:
18685 376 return true;
18686
18687
18688 case eeDIG:
18689 {
18690
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
✓ Branch 2 taken 75 times.
201 switch(guysbuf[id].attributes[9])
18691 {
18692 case 1:
18693
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 47 times.
126 if(!get_qr(qr_NOTMPNORET))
18694 79 return !getmapflag(mTMPNORET);
18695
18696 47 return true;
18697
18698 75 case 0:
18699 default:
18700 75 return true;
18701 }
18702 }
18703 case eeGANON:
18704 case eeTRAP:
18705
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
128 if ((guysbuf[id].family == eeGANON && !get_qr(qr_CAN_PLACE_GANON))
18706
4/4
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 64 times.
✓ Branch 3 taken 64 times.
64 || (guysbuf[id].family == eeTRAP && !get_qr(qr_CAN_PLACE_TRAPS))) return false;
18707 [[fallthrough]];
18708 default:
18709
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 81667 times.
81667 if (guysbuf[id].flags&guy_ignoretmpnr) return true;
18710 81667 break;
18711 }
18712
18713
2/2
✓ Branch 0 taken 20879 times.
✓ Branch 1 taken 60788 times.
81667 if(!get_qr(qr_NOTMPNORET))
18714 60788 return !getmapflag(mTMPNORET);
18715
18716 20879 return true;
18717 82772 }
18718
18719 1410596 void activate_fireball_statue(int32_t pos)
18720 {
18721
3/4
✓ Branch 0 taken 287797 times.
✓ Branch 1 taken 1122799 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 287797 times.
1410596 if(!(tmpscr->enemyflags&efFIREBALLS) || statueID<0)
18722 {
18723 1122799 return;
18724 }
18725
18726 287797 int32_t cx=-1000, cy=-1000;
18727 287797 int32_t x = (pos&15)<<4;
18728 287797 int32_t y = pos&0xF0;
18729
18730 287797 int32_t ctype = combobuf[MAPCOMBO(x,y)].type;
18731
18732
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 287797 times.
287797 if(!isfixedtogrid(statueID))
18733 {
18734
2/2
✓ Branch 0 taken 1508 times.
✓ Branch 1 taken 286289 times.
287797 if(ctype==cL_STATUE)
18735 {
18736 1508 cx=x+4;
18737 1508 cy=y+7;
18738 1508 }
18739
2/2
✓ Branch 0 taken 1315 times.
✓ Branch 1 taken 284974 times.
286289 else if(ctype==cR_STATUE)
18740 {
18741 1315 cx=x-8;
18742 1315 cy=y-1;
18743 1315 }
18744
2/2
✓ Branch 0 taken 283761 times.
✓ Branch 1 taken 1213 times.
284974 else if(ctype==cC_STATUE)
18745 {
18746 1213 cx=x;
18747 1213 cy=y;
18748 1213 }
18749 287797 }
18750 else if(ctype==cL_STATUE || ctype==cR_STATUE || ctype==cC_STATUE)
18751 {
18752 cx=x;
18753 cy=y;
18754 }
18755
18756
2/2
✓ Branch 0 taken 283761 times.
✓ Branch 1 taken 4036 times.
287797 if(cx!=-1000) // No point creating it if this is false
18757 {
18758
2/2
✓ Branch 0 taken 9754 times.
✓ Branch 1 taken 4032 times.
13786 for(int32_t j=0; j<guys.Count(); j++)
18759 {
18760
4/4
✓ Branch 0 taken 1698 times.
✓ Branch 1 taken 8056 times.
✓ Branch 2 taken 1694 times.
✓ Branch 3 taken 4 times.
9754 if((int32_t(guys.spr(j)->x)==cx)&&(int32_t(guys.spr(j)->y)==cy))
18761 {
18762
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if((guys.spr(j)->id&0xFFF) == statueID) // There's already a matching enemy here!
18763 4 return; // No point deleting it. A script might be toying with it in some way.
18764 else
18765 guys.del(j);
18766 }
18767 9750 }
18768
18769 4032 addenemy(cx, cy, statueID, !isfixedtogrid(statueID) ? 24 : 0);
18770 4032 }
18771 1410596 }
18772
18773 34919 void activate_fireball_statues()
18774 {
18775
2/2
✓ Branch 0 taken 1413 times.
✓ Branch 1 taken 33506 times.
34919 if(!(tmpscr->enemyflags&efFIREBALLS))
18776 {
18777 33506 return;
18778 }
18779
18780
2/2
✓ Branch 0 taken 1413 times.
✓ Branch 1 taken 248688 times.
250101 for(int32_t i=0; i<176; i++)
18781 {
18782 248688 activate_fireball_statue(i);
18783 248688 }
18784 34919 }
18785
18786 34919 void load_default_enemies()
18787 {
18788 34919 wallm_load_clk=frame-80;
18789
18790
2/2
✓ Branch 0 taken 33039 times.
✓ Branch 1 taken 1880 times.
34919 if(tmpscr->enemyflags&efZORA)
18791 {
18792
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1880 times.
1880 if(zoraID>=0)
18793 1880 addenemy(-16, -16, zoraID, 0);
18794 1880 }
18795
18796
2/2
✓ Branch 0 taken 34741 times.
✓ Branch 1 taken 178 times.
34919 if(tmpscr->enemyflags&efTRAP4)
18797 {
18798
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 178 times.
178 if(cornerTrapID>=0)
18799 {
18800 178 addenemy(32, 32, cornerTrapID, -14);
18801 178 addenemy(208, 32, cornerTrapID, -14);
18802 178 addenemy(32, 128, cornerTrapID, -14);
18803 178 addenemy(208, 128, cornerTrapID, -14);
18804 178 }
18805 178 }
18806
18807
2/2
✓ Branch 0 taken 384109 times.
✓ Branch 1 taken 34919 times.
419028 for(int32_t y=0; y<176; y+=16)
18808 {
18809
2/2
✓ Branch 0 taken 6145744 times.
✓ Branch 1 taken 384109 times.
6529853 for(int32_t x=0; x<256; x+=16)
18810 {
18811 6145744 int32_t ctype = combobuf[MAPCOMBO(x,y)].type;
18812 6145744 int32_t cflag = MAPFLAG(x, y);
18813 6145744 int32_t cflag_i = MAPCOMBOFLAG(x, y);
18814
18815
4/6
✓ Branch 0 taken 6145744 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6145438 times.
✓ Branch 3 taken 306 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6145438 times.
6145744 if(ctype==cTRAP_H || cflag==mfTRAP_H || cflag_i==mfTRAP_H)
18816 {
18817
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 296 times.
306 if(trapLOSHorizontalID>=0)
18818 296 addenemy(x, y, trapLOSHorizontalID, -14);
18819 306 }
18820
4/6
✓ Branch 0 taken 6145438 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6145232 times.
✓ Branch 3 taken 206 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6145232 times.
6145438 else if(ctype==cTRAP_V || cflag==mfTRAP_V || cflag_i==mfTRAP_V)
18821 {
18822
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 206 times.
206 if(trapLOSVerticalID>=0)
18823 206 addenemy(x, y, trapLOSVerticalID, -14);
18824 206 }
18825
4/6
✓ Branch 0 taken 6145232 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6144954 times.
✓ Branch 3 taken 278 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6144954 times.
6145232 else if(ctype==cTRAP_4 || cflag==mfTRAP_4 || cflag_i==mfTRAP_4)
18826 {
18827
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 278 times.
278 if(trapLOS4WayID>=0)
18828 {
18829
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 278 times.
278 if(addenemy(x, y, trapLOS4WayID, -14))
18830 278 guys.spr(guys.Count()-1)->dummy_int[1]=2;
18831 278 }
18832 278 }
18833
18834
4/6
✓ Branch 0 taken 6144954 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6144555 times.
✓ Branch 3 taken 399 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6144555 times.
6144954 else if(ctype==cTRAP_LR || cflag==mfTRAP_LR || cflag_i==mfTRAP_LR)
18835 {
18836
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 399 times.
399 if(trapConstantHorizontalID>=0)
18837 399 addenemy(x, y, trapConstantHorizontalID, -14);
18838 399 }
18839
4/6
✓ Branch 0 taken 6144555 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6144122 times.
✓ Branch 3 taken 433 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6144122 times.
6144555 else if(ctype==cTRAP_UD || cflag==mfTRAP_UD || cflag_i==mfTRAP_UD)
18840 {
18841
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 433 times.
433 if(trapConstantVerticalID>=0)
18842 433 addenemy(x, y, trapConstantVerticalID, -14);
18843 433 }
18844
18845
1/2
✓ Branch 0 taken 6145744 times.
✗ Branch 1 not taken.
6145744 if(ctype==cSPINTILE1)
18846 {
18847 // Awaken spinning tile
18848 awaken_spinning_tile(tmpscr,COMBOPOS(x,y));
18849 }
18850 6145744 }
18851 384109 }
18852
18853
2/2
✓ Branch 0 taken 34863 times.
✓ Branch 1 taken 56 times.
34919 if(tmpscr->enemyflags&efTRAP2)
18854 {
18855
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56 times.
56 if(centerTrapID>=-1)
18856 {
18857
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56 times.
56 if(addenemy(64, 80, centerTrapID, -14))
18858 56 guys.spr(guys.Count()-1)->dummy_int[1]=1;
18859
18860
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56 times.
56 if(addenemy(176, 80, centerTrapID, -14))
18861 56 guys.spr(guys.Count()-1)->dummy_int[1]=1;
18862 56 }
18863 56 }
18864
18865
2/2
✓ Branch 0 taken 34836 times.
✓ Branch 1 taken 83 times.
34919 if(tmpscr->enemyflags&efROCKS)
18866 {
18867
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 83 times.
83 if(rockID>=0)
18868 {
18869 83 addenemy(zc_oldrand()&0xF0, 0, rockID, 0);
18870 83 addenemy(zc_oldrand()&0xF0, 0, rockID, 0);
18871 83 addenemy(zc_oldrand()&0xF0, 0, rockID, 0);
18872 83 }
18873 83 }
18874
18875 34919 activate_fireball_statues();
18876 34919 }
18877
18878 #define SLOPE_STAGE_COMBOS 0
18879 #define SLOPE_STAGE_FFCS 1
18880 #define SLOPE_STAGE_COMBOS_BORDERING_SCREENS 2
18881
18882 50008399 static int create_slope_id(int stage, int arg1, int arg2)
18883 {
18884
2/2
✓ Branch 0 taken 5440330 times.
✓ Branch 1 taken 44568069 times.
50008399 if (stage == SLOPE_STAGE_COMBOS)
18885 44568069 return (176*arg1)+arg2;
18886
2/2
✓ Branch 0 taken 5329619 times.
✓ Branch 1 taken 110711 times.
5440330 if (stage == SLOPE_STAGE_FFCS)
18887 5329619 return (176*7)+arg1;
18888
1/2
✓ Branch 0 taken 110711 times.
✗ Branch 1 not taken.
110711 if (stage == SLOPE_STAGE_COMBOS_BORDERING_SCREENS)
18889 110711 return (176*7 + MAXFFCS)+arg1*7*(16 * 2 + 11 * 2) + arg2;
18890 // TODO: what about FFCs from bordering screens?
18891
18892 assert(false);
18893 return 0;
18894 50008399 }
18895
18896 44568069 void update_slope_combopos(int32_t lyr, int32_t pos)
18897 {
18898
2/4
✓ Branch 0 taken 44568069 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 44568069 times.
44568069 if(unsigned(lyr) > 6 || unsigned(pos) > 175) return;
18899 44568069 mapscr* s = FFCore.tempScreens[lyr];
18900 44568069 newcombo const& cmb = combobuf[s->data[pos]];
18901
18902 44568069 auto id = create_slope_id(SLOPE_STAGE_COMBOS, lyr, pos);
18903 44568069 auto it = slopes.find(id);
18904
18905 44568069 bool wasSlope = it!=slopes.end();
18906 44568069 bool isSlope = cmb.type == cSLOPE;
18907
18908
3/4
✓ Branch 0 taken 136 times.
✓ Branch 1 taken 44567933 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 136 times.
44568069 if(isSlope && !wasSlope)
18909 {
18910 136 slopes.try_emplace(id, &(s->data[pos]), nullptr, -1, COMBOX(pos), COMBOY(pos));
18911 136 }
18912
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 44567933 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
44567933 else if(wasSlope && !isSlope)
18913 {
18914 slopes.erase(it);
18915 }
18916 44568069 }
18917
18918 110711 static void update_slope_combopos_bordering_screen(int dir, int slope_count, int cid, bool is_slope, int offx, int offy)
18919 {
18920 110711 auto id = create_slope_id(SLOPE_STAGE_COMBOS_BORDERING_SCREENS, dir, slope_count);
18921 110711 auto it = slopes.find(id);
18922
18923 110711 bool wasSlope = it!=slopes.end();
18924 110711 bool isSlope = is_slope;
18925
18926
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 110711 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
110711 if(isSlope && !wasSlope)
18927 {
18928 static word TMP[5000];
18929 int tmp_index = id-create_slope_id(SLOPE_STAGE_COMBOS_BORDERING_SCREENS,0,0);
18930 TMP[tmp_index] = cid;
18931 slopes.try_emplace(id, &TMP[tmp_index], nullptr, -1, offx, offy);
18932 }
18933
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 110711 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
110711 else if(wasSlope && !isSlope)
18934 {
18935 slopes.erase(it);
18936 }
18937 110711 }
18938
18939 // Load a single column or row from a nearby screen, and load its slopes.
18940 2972 static void handle_slope_combopos_bordering_screen(int dir)
18941 {
18942 int mi;
18943
2/2
✓ Branch 0 taken 2857 times.
✓ Branch 1 taken 115 times.
2972 if (auto r = nextscr(dir, true))
18944 2857 mi = *r;
18945 else
18946 115 return;
18947
18948 2857 int map = mi / MAPSCRSNORMAL;
18949 2857 int screen = mi % MAPSCRSNORMAL;
18950
18951 2857 int offx = 0;
18952 2857 int offy = 0;
18953
2/2
✓ Branch 0 taken 2166 times.
✓ Branch 1 taken 691 times.
2857 if (dir == up)
18954 691 offy = -16;
18955
2/2
✓ Branch 0 taken 684 times.
✓ Branch 1 taken 1482 times.
2166 else if (dir == down)
18956 684 offy = 176;
18957
2/2
✓ Branch 0 taken 740 times.
✓ Branch 1 taken 742 times.
1482 else if (dir == left)
18958 740 offx = -16;
18959
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 742 times.
742 else if (dir == right)
18960 742 offx = 256;
18961
18962
2/2
✓ Branch 0 taken 2857 times.
✓ Branch 1 taken 19999 times.
22856 for (int layer = 0; layer < 7; layer++)
18963 {
18964 19999 auto scr = load_temp_mapscr_and_apply_secrets(map, screen, layer - 1, true, false);
18965
2/2
✓ Branch 0 taken 8261 times.
✓ Branch 1 taken 11738 times.
19999 if (!scr) continue;
18966
18967 8261 int slope_count = layer * (16*2);
18968
18969
4/4
✓ Branch 0 taken 6118 times.
✓ Branch 1 taken 2143 times.
✓ Branch 2 taken 2150 times.
✓ Branch 3 taken 3968 times.
8261 if (dir == left || dir == right)
18970 {
18971 4293 int x = dir == left ? 15 : 0;
18972
2/2
✓ Branch 0 taken 47223 times.
✓ Branch 1 taken 4293 times.
51516 for (int y = 0; y < 11; y++)
18973 {
18974 47223 int pos = y * 16 + x;
18975 47223 int cid = scr->data[pos];
18976 47223 bool is_slope = combobuf[cid].type == cSLOPE;
18977
1/2
✓ Branch 0 taken 47223 times.
✗ Branch 1 not taken.
47223 update_slope_combopos_bordering_screen(dir, slope_count++, cid, is_slope, offx, offy + y*16);
18978 47223 }
18979 4293 }
18980
3/4
✓ Branch 0 taken 1963 times.
✓ Branch 1 taken 2005 times.
✓ Branch 2 taken 1963 times.
✗ Branch 3 not taken.
3968 else if (dir == up || dir == down)
18981 {
18982 3968 int y = dir == up ? 10 : 0;
18983
2/2
✓ Branch 0 taken 63488 times.
✓ Branch 1 taken 3968 times.
67456 for (int x = 0; x < 16; x++)
18984 {
18985 63488 int pos = y * 16 + x;
18986 63488 int cid = scr->data[pos];
18987 63488 bool is_slope = combobuf[cid].type == cSLOPE;
18988
1/2
✓ Branch 0 taken 63488 times.
✗ Branch 1 not taken.
63488 update_slope_combopos_bordering_screen(dir, slope_count++, cid, is_slope, offx + x*16, offy);
18989 63488 }
18990 3968 }
18991
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 11738 times.
✓ Branch 2 taken 8261 times.
19999 }
18992 2972 }
18993
18994 35292 void update_slope_comboposes()
18995 {
18996
2/2
✓ Branch 0 taken 35292 times.
✓ Branch 1 taken 247044 times.
282336 for(auto lyr = 0; lyr < 7; ++lyr)
18997 {
18998
2/2
✓ Branch 0 taken 43479744 times.
✓ Branch 1 taken 247044 times.
43726788 for(auto pos = 0; pos < 176; ++pos)
18999 43479744 update_slope_combopos(lyr,pos);
19000 247044 }
19001
19002
2/2
✓ Branch 0 taken 34549 times.
✓ Branch 1 taken 743 times.
35292 if (Hero.sideview_mode())
19003 {
19004
2/2
✓ Branch 0 taken 2972 times.
✓ Branch 1 taken 743 times.
3715 for (int dir = up; dir <= right; dir++)
19005 2972 handle_slope_combopos_bordering_screen(dir);
19006 743 }
19007
19008 35292 update_slopes();
19009 35292 }
19010
19011 // Everything that must be done before we change a screen's combo to another combo, or a combo's type to another type.
19012 // There's 2 routines because it's unclear if combobuf or tmpscr->data gets modified. -L
19013 1161908 void screen_combo_modify_preroutine(mapscr *s, int32_t pos)
19014 {
19015 1161908 delete_fireball_shooter(s, pos);
19016 1161908 }
19017
19018 //Placeholder in case we need it.
19019 void screen_ffc_modify_preroutine(word index)
19020 {
19021 return;
19022 }
19023
19024 // Everything that must be done after we change a screen's combo to another combo. -L
19025 1161908 void screen_combo_modify_postroutine(mapscr *s, int32_t pos)
19026 {
19027 1161908 s->valid |= mVALID;
19028 1161908 activate_fireball_statue(pos);
19029
19030
2/2
✓ Branch 0 taken 1161814 times.
✓ Branch 1 taken 94 times.
1161908 if(combobuf[s->data[pos]].type==cSPINTILE1)
19031 {
19032 // Awaken spinning tile
19033 94 awaken_spinning_tile(s,pos);
19034 94 }
19035 1161908 int32_t lyr = -1;
19036
2/2
✓ Branch 0 taken 119833 times.
✓ Branch 1 taken 1042075 times.
1161908 if(s == tmpscr) lyr = 0;
19037
2/2
✓ Branch 0 taken 73583 times.
✓ Branch 1 taken 598310 times.
671893 else for(size_t q = 0; q < 6; ++q)
19038 {
19039
2/2
✓ Branch 0 taken 46250 times.
✓ Branch 1 taken 552060 times.
598310 if(s == tmpscr2+q)
19040 {
19041 46250 lyr = q+1;
19042 46250 break;
19043 }
19044 552060 }
19045
2/2
✓ Branch 0 taken 73583 times.
✓ Branch 1 taken 1088325 times.
1161908 if(lyr > -1)
19046 1088325 update_slope_combopos(lyr,pos);
19047 1161908 }
19048
19049 5329619 void screen_ffc_modify_postroutine(word index)
19050 {
19051 5329619 ffcdata& ff = tmpscr->ffcs[index];
19052 5329619 newcombo const& cmb = combobuf[ff.data];
19053
19054 5329619 auto id = create_slope_id(SLOPE_STAGE_FFCS, index, -1);
19055 5329619 auto it = slopes.find(id);
19056
19057 5329619 bool wasSlope = it!=slopes.end();
19058
1/2
✓ Branch 0 taken 5329619 times.
✗ Branch 1 not taken.
5329619 bool isSlope = cmb.type == cSLOPE && !(ff.flags&ffc_changer);
19059
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5329619 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5329619 if(isSlope && !wasSlope)
19060 {
19061 slopes.try_emplace(id, nullptr, &ff, index);
19062 }
19063
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5329619 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5329619 else if(wasSlope && !isSlope)
19064 {
19065 slopes.erase(it);
19066 }
19067
19068 5329619 tmpscr->ffcCountMarkDirty();
19069 5329619 }
19070
19071 4404 void screen_combo_modify_pre(int32_t cid)
19072 {
19073
2/2
✓ Branch 0 taken 30828 times.
✓ Branch 1 taken 4404 times.
35232 for(auto lyr = 0; lyr < 7; ++lyr)
19074 {
19075 30828 mapscr* t = FFCore.tempScreens[lyr];
19076
2/2
✓ Branch 0 taken 5425728 times.
✓ Branch 1 taken 30828 times.
5456556 for(int32_t i = 0; i < 176; i++)
19077 {
19078
2/2
✓ Branch 0 taken 5419127 times.
✓ Branch 1 taken 6601 times.
5425728 if(t->data[i] == cid)
19079 {
19080 6601 screen_combo_modify_preroutine(t,i);
19081 6601 }
19082 5425728 }
19083 30828 }
19084 4404 }
19085 4404 void screen_combo_modify_post(int32_t cid)
19086 {
19087
2/2
✓ Branch 0 taken 30828 times.
✓ Branch 1 taken 4404 times.
35232 for(auto lyr = 0; lyr < 7; ++lyr)
19088 {
19089 30828 mapscr* t = FFCore.tempScreens[lyr];
19090
2/2
✓ Branch 0 taken 5425728 times.
✓ Branch 1 taken 30828 times.
5456556 for(int32_t i = 0; i < 176; i++)
19091 {
19092
2/2
✓ Branch 0 taken 5419127 times.
✓ Branch 1 taken 6601 times.
5425728 if(t->data[i] == cid)
19093 {
19094 6601 screen_combo_modify_postroutine(t,i);
19095 6601 }
19096 5425728 }
19097 30828 }
19098 4404 int c = tmpscr->numFFC();
19099
2/2
✓ Branch 0 taken 139510 times.
✓ Branch 1 taken 4404 times.
143914 for(word ind = 0; ind < c; ++ind)
19100 {
19101
2/2
✓ Branch 0 taken 139452 times.
✓ Branch 1 taken 58 times.
139510 if(tmpscr->ffcs[ind].data == cid)
19102 58 screen_ffc_modify_postroutine(ind);
19103 139510 }
19104 4404 }
19105
19106 94 void awaken_spinning_tile(mapscr *s, int32_t pos)
19107 {
19108
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
94 addenemy((pos&15)<<4,pos&0xF0,(s->cset[pos]<<12)+eSPINTILE1,combobuf[s->data[pos]].o_tile+zc_max(1,combobuf[s->data[pos]].frames));
19109 94 }
19110
19111
19112 // It stands for next_side_pos
19113 11436 void nsp(bool random)
19114 // moves sle_x and sle_y to the next position
19115 {
19116
2/2
✓ Branch 0 taken 3261 times.
✓ Branch 1 taken 8175 times.
11436 if(random)
19117 {
19118
2/2
✓ Branch 0 taken 1634 times.
✓ Branch 1 taken 1627 times.
3261 if(zc_oldrand()%2)
19119 {
19120 1634 sle_x = (zc_oldrand()%2) ? 0 : 240;
19121 1634 sle_y = (zc_oldrand()%10)*16;
19122 1634 }
19123 else
19124 {
19125 1627 sle_y = (zc_oldrand()%2) ? 0 : 160;
19126 1627 sle_x = (zc_oldrand()%15)*16;
19127 }
19128
19129 3261 return;
19130 }
19131
19132
2/2
✓ Branch 0 taken 6151 times.
✓ Branch 1 taken 2024 times.
8175 if(sle_x==0)
19133 {
19134
2/2
✓ Branch 0 taken 1845 times.
✓ Branch 1 taken 179 times.
2024 if(sle_y<160)
19135 1845 sle_y+=16;
19136 else
19137 179 sle_x+=16;
19138 2024 }
19139
2/2
✓ Branch 0 taken 2581 times.
✓ Branch 1 taken 3570 times.
6151 else if(sle_y==160)
19140 {
19141
2/2
✓ Branch 0 taken 2416 times.
✓ Branch 1 taken 165 times.
2581 if(sle_x<240)
19142 2416 sle_x+=16;
19143 else
19144 165 sle_y-=16;
19145 2581 }
19146
2/2
✓ Branch 0 taken 1550 times.
✓ Branch 1 taken 2020 times.
3570 else if(sle_x==240)
19147 {
19148
2/2
✓ Branch 0 taken 1402 times.
✓ Branch 1 taken 148 times.
1550 if(sle_y>0)
19149 1402 sle_y-=16;
19150 else
19151 148 sle_x-=16;
19152 1550 }
19153
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2020 times.
2020 else if(sle_y==0)
19154 {
19155
1/2
✓ Branch 0 taken 2020 times.
✗ Branch 1 not taken.
2020 if(sle_x>0)
19156 2020 sle_x-=16;
19157 else
19158 sle_y+=16;
19159 2020 }
19160 11436 }
19161
19162 2426 int32_t next_side_pos(bool random)
19163 // moves sle_x and sle_y to the next available position
19164 // returns the direction the enemy should face
19165 {
19166 bool blocked;
19167 2426 int32_t c=0;
19168
19169 2426 do
19170 {
19171
2/2
✓ Branch 0 taken 131 times.
✓ Branch 1 taken 11305 times.
11436 nsp(c>35 ? false : random);
19172
4/4
✓ Branch 0 taken 2444 times.
✓ Branch 1 taken 8992 times.
✓ Branch 2 taken 19 times.
✓ Branch 3 taken 2425 times.
13861 blocked = _walkflag(sle_x,sle_y,2) || _walkflag(sle_x,sle_y+8,2) ||
19173
1/2
✓ Branch 0 taken 2425 times.
✗ Branch 1 not taken.
2425 (combo_class_buf[COMBOTYPE(sle_x,sle_y)].block_enemies ||
19174
2/4
✓ Branch 0 taken 2425 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2425 times.
✗ Branch 3 not taken.
2425 MAPFLAG(sle_x,sle_y) == mfNOENEMY || MAPCOMBOFLAG(sle_x,sle_y)==mfNOENEMY ||
19175
2/4
✓ Branch 0 taken 2425 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2425 times.
2425 MAPFLAG(sle_x,sle_y) == mfNOGROUNDENEMY || MAPCOMBOFLAG(sle_x,sle_y)==mfNOGROUNDENEMY ||
19176 2425 iswaterex(MAPCOMBO(sle_x,sle_y), currmap, currscr, -1, sle_x, sle_y, true));
19177
19178
2/2
✓ Branch 0 taken 11435 times.
✓ Branch 1 taken 1 times.
11436 if(++c>50)
19179 1 return -1;
19180
2/2
✓ Branch 0 taken 9010 times.
✓ Branch 1 taken 2425 times.
11435 }
19181 11435 while(blocked);
19182
19183 2425 int32_t dir=0;
19184
19185
2/2
✓ Branch 0 taken 1690 times.
✓ Branch 1 taken 735 times.
2425 if(sle_x==0) dir=right;
19186
19187
2/2
✓ Branch 0 taken 1856 times.
✓ Branch 1 taken 569 times.
2425 if(sle_y==0) dir=down;
19188
19189
2/2
✓ Branch 0 taken 1719 times.
✓ Branch 1 taken 706 times.
2425 if(sle_x==240) dir=left;
19190
19191
1/2
✓ Branch 0 taken 2425 times.
✗ Branch 1 not taken.
2425 if(sle_y==168) dir=up;
19192
19193 2425 return dir;
19194 2426 }
19195
19196 bool can_side_load(int32_t id)
19197 {
19198 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
19199 {
19200 return false;
19201 }
19202 switch(guysbuf[id].family) //id&0x0FFF)
19203 {
19204 //case eTEK1:
19205 //case eTEK2:
19206 //case eTEK3:
19207 //case eLEV1:
19208 //case eLEV2:
19209 //case eLEV3:
19210 //case eRAQUAM:
19211 //case eLAQUAM:
19212 //case eDODONGO:
19213 //case eMANHAN:
19214 //case eGLEEOK1:
19215 //case eGLEEOK2:
19216 //case eGLEEOK3:
19217 //case eGLEEOK4:
19218 //case eDIG1:
19219 //case eDIG3:
19220 //case eGOHMA1:
19221 //case eGOHMA2:
19222 //case eCENT1:
19223 //case eCENT2:
19224 //case ePATRA1:
19225 //case ePATRA2:
19226 //case eGANON:
19227 //case eMANHAN2:
19228 //case eCEILINGM: later
19229 //case eFLOORM: later
19230 //case ePATRABS:
19231 //case ePATRAL2:
19232 //case ePATRAL3:
19233 //case eGLEEOK1F:
19234 //case eGLEEOK2F:
19235 //case eGLEEOK3F:
19236 //case eGLEEOK4F:
19237 //case eDODONGOBS:
19238 //case eDODONGOF:
19239 //case eGOHMA3:
19240 //case eGOHMA4:
19241 //case eSHOOTMAGIC:
19242 //case eSHOOTROCK:
19243 //case eSHOOTSPEAR:
19244 //case eSHOOTSWORD:
19245 //case eSHOOTFLAME:
19246 //case eSHOOTFLAME2:
19247 //case eSHOOTFBALL:
19248 case eeTEK:
19249 case eeLEV:
19250 case eeAQUA:
19251 case eeDONGO:
19252 case eeMANHAN:
19253 case eeGLEEOK:
19254 case eeDIG:
19255 case eeGHOMA:
19256 case eeLANM:
19257 case eePATRA:
19258 case eeGANON:
19259 case eePROJECTILE:
19260 return false;
19261 break;
19262 }
19263
19264 return true;
19265 }
19266
19267 static bool script_sle = false;
19268 static int32_t sle_pattern = 0;
19269 void script_side_load_enemies()
19270 {
19271 if(script_sle || sle_clk) return;
19272 sle_cnt = 0;
19273 while(sle_cnt<10 && tmpscr->enemy[sle_cnt]!=0)
19274 ++sle_cnt;
19275 script_sle = true;
19276 sle_pattern = tmpscr->pattern;
19277 sle_clk = 0;
19278 }
19279
19280 54442 void side_load_enemies()
19281 {
19282
3/4
✓ Branch 0 taken 54442 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 53760 times.
✓ Branch 3 taken 682 times.
54442 if(!script_sle && sle_clk==0)
19283 {
19284 682 sle_pattern = tmpscr->pattern;
19285 682 sle_cnt = 0;
19286 682 int32_t guycnt = 0;
19287 682 int16_t s = (currmap<<7)+currscr;
19288 682 bool beenhere=false;
19289 682 bool reload=true;
19290 682 bool unbeatablereload = true;
19291
19292 682 load_default_enemies();
19293
19294
2/2
✓ Branch 0 taken 4092 times.
✓ Branch 1 taken 682 times.
4774 for(int32_t i=0; i<6; i++)
19295
2/2
✓ Branch 0 taken 3889 times.
✓ Branch 1 taken 203 times.
4295 if(visited[i]==s)
19296 203 beenhere=true;
19297
19298
2/2
✓ Branch 0 taken 203 times.
✓ Branch 1 taken 479 times.
682 if(!beenhere)
19299 {
19300 479 visited[vhead]=s;
19301 479 vhead = (vhead+1)%6;
19302 479 }
19303
2/2
✓ Branch 0 taken 161 times.
✓ Branch 1 taken 42 times.
203 else if(game->guys[s]==0)
19304 {
19305 42 sle_cnt=0;
19306 42 reload=false;
19307 42 }
19308
19309
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 640 times.
682 if(reload)
19310 {
19311 640 sle_cnt = game->guys[s];
19312
19313
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 640 times.
✓ Branch 2 taken 420 times.
✓ Branch 3 taken 220 times.
640 if((get_qr(qr_NO_LEAVE_ONE_ENEMY_ALIVE_TRICK) && !beenhere)
19314 640 || sle_cnt==0)
19315 {
19316
4/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1267 times.
✓ Branch 2 taken 1050 times.
✓ Branch 3 taken 220 times.
1270 while(sle_cnt<10 && tmpscr->enemy[sle_cnt]!=0)
19317 1050 ++sle_cnt;
19318 220 }
19319
3/4
✓ Branch 0 taken 479 times.
✓ Branch 1 taken 161 times.
✓ Branch 2 taken 479 times.
✗ Branch 3 not taken.
640 if (!beenhere && get_qr(qr_UNBEATABLES_DONT_KEEP_DEAD))
19320 {
19321 for(int32_t i = 0; i<sle_cnt && tmpscr->enemy[i]>0; i++)
19322 {
19323 if (!(guysbuf[tmpscr->enemy[i]].flags & guy_doesnt_count))
19324 {
19325 unbeatablereload = false;
19326 }
19327 }
19328 if (unbeatablereload)
19329 {
19330 while(sle_cnt<10 && tmpscr->enemy[sle_cnt]!=0)
19331 {
19332 ++sle_cnt;
19333 }
19334 }
19335 }
19336 640 }
19337
19338
3/4
✓ Branch 0 taken 651 times.
✓ Branch 1 taken 31 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 651 times.
682 if((get_qr(qr_ALWAYSRET)) || (tmpscr->flags3&fENEMIESRETURN))
19339 {
19340 31 sle_cnt = 0;
19341
19342
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
✓ Branch 2 taken 108 times.
✓ Branch 3 taken 31 times.
139 while(sle_cnt<10 && tmpscr->enemy[sle_cnt]!=0)
19343 108 ++sle_cnt;
19344 31 }
19345
19346
2/2
✓ Branch 0 taken 2442 times.
✓ Branch 1 taken 682 times.
3124 for(int32_t i=0; i<sle_cnt; i++)
19347 2442 ++guycnt;
19348
19349 682 game->guys[s] = guycnt;
19350 682 }
19351
19352
2/2
✓ Branch 0 taken 52016 times.
✓ Branch 1 taken 2426 times.
54442 if((++sle_clk+8)%24 == 0)
19353 {
19354 2426 int32_t dir = next_side_pos(sle_pattern==pSIDESR);
19355
19356
4/4
✓ Branch 0 taken 2425 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 232 times.
✓ Branch 3 taken 2193 times.
2426 if(dir==-1 || tooclose(sle_x,sle_y,32))
19357 {
19358 233 return;
19359 }
19360
19361 2193 int32_t enemy_slot=guys.Count();
19362
19363
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2193 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2193 times.
2193 while(sle_cnt > 0 && !ok2add(tmpscr->enemy[sle_cnt-1]))
19364 sle_cnt--;
19365
19366
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2193 times.
2193 if(sle_cnt > 0)
19367 {
19368
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2193 times.
2193 if(addenemy(sle_x,sle_y,tmpscr->enemy[--sle_cnt],0))
19369 {
19370
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2193 times.
2193 if (((enemy*)guys.spr(enemy_slot))->family != eeTEK)
19371 {
19372 2193 guys.spr(enemy_slot)->dir = dir;
19373 2193 }
19374
1/2
✓ Branch 0 taken 2193 times.
✗ Branch 1 not taken.
2193 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
19375 {
19376 if (!FFCore.system_suspend[susptNPCSCRIPTS])
19377 {
19378 guys.spr(enemy_slot)->run_script(MODE_NORMAL);
19379 ((enemy*)guys.spr(enemy_slot))->didScriptThisFrame = true;
19380 }
19381 }
19382 2193 }
19383 2193 }
19384 2193 }
19385
19386
2/2
✓ Branch 0 taken 53631 times.
✓ Branch 1 taken 578 times.
54209 if(sle_cnt<=0)
19387 {
19388
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 578 times.
578 if(script_sle)
19389 script_sle = false;
19390 578 else loaded_enemies=true;
19391 578 sle_clk = 0;
19392 578 }
19393 54442 }
19394
19395 1208109 bool is_starting_pos(int32_t i, int32_t x, int32_t y, int32_t t)
19396 {
19397
19398
4/4
✓ Branch 0 taken 1105225 times.
✓ Branch 1 taken 102884 times.
✓ Branch 2 taken 102884 times.
✓ Branch 3 taken 1208109 times.
1208109 if(tmpscr->enemy[i]<1||tmpscr->enemy[i]>=MAXGUYS) //Hackish fix for crash in Waterford.st on screen 0x65 of dmap 0 (map 1).
19399 {
19400 205768 return false; //never 0, never OoB.
19401 }
19402 // No corner enemies
19403
6/6
✓ Branch 0 taken 1042349 times.
✓ Branch 1 taken 165760 times.
✓ Branch 2 taken 40016 times.
✓ Branch 3 taken 1082365 times.
✓ Branch 4 taken 114320 times.
✓ Branch 5 taken 91456 times.
1208109 if((x==0 || x==240) && (y==0 || y==160))
19404
19405 205776 return false;
19406
19407 //Is a no spawn combo...
19408
4/4
✓ Branch 0 taken 1082353 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 1082357 times.
1082365 if(MAPFLAG(x+8,y+8)==mfNOENEMYSPAWN || MAPCOMBOFLAG(x+8,y+8)==mfNOENEMYSPAWN)
19409 16 return false;
19410
19411 // No enemies in dungeon walls
19412
10/10
✓ Branch 0 taken 655073 times.
✓ Branch 1 taken 427284 times.
✓ Branch 2 taken 582513 times.
✓ Branch 3 taken 72560 times.
✓ Branch 4 taken 509953 times.
✓ Branch 5 taken 72560 times.
✓ Branch 6 taken 422881 times.
✓ Branch 7 taken 87072 times.
✓ Branch 8 taken 87072 times.
✓ Branch 9 taken 335809 times.
1082357 if(isdungeon() && (x<32 || x>=224 || y<32 || y>=144))
19413 319264 return false;
19414
19415 // Too close
19416
4/4
✓ Branch 0 taken 74233 times.
✓ Branch 1 taken 688860 times.
✓ Branch 2 taken 101 times.
✓ Branch 3 taken 74132 times.
763093 if(tooclose(x,y,40) && t<11)
19417 74132 return false;
19418
19419 // Can't fly onto it?
19420
4/4
✓ Branch 0 taken 122271 times.
✓ Branch 1 taken 566690 times.
✓ Branch 2 taken 35960 times.
✓ Branch 3 taken 17932 times.
742853 if(isflier(tmpscr->enemy[i])&&
19421
2/2
✓ Branch 0 taken 121881 times.
✓ Branch 1 taken 390 times.
122271 (flyerblocked(x+8,y+8,spw_floater,guysbuf[tmpscr->enemy[i]])||
19422
2/2
✓ Branch 0 taken 53892 times.
✓ Branch 1 taken 67989 times.
121881 (_walkflag(x,y+8,2)&&!get_qr(qr_WALLFLIERS))))
19423 18322 return false;
19424
19425 // Can't jump onto it?
19426 if
19427 (
19428
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 86588 times.
757231 guysbuf[tmpscr->enemy[i]].family==eeTEK
19429
19430
2/2
✓ Branch 0 taken 86606 times.
✓ Branch 1 taken 584033 times.
670639 &&
19431 (
19432
2/2
✓ Branch 0 taken 86599 times.
✓ Branch 1 taken 7 times.
86606 COMBOTYPE(x+8,y+8)==cNOJUMPZONE||
19433
2/2
✓ Branch 0 taken 86598 times.
✓ Branch 1 taken 1 times.
86599 COMBOTYPE(x+8,y+8)==cNOENEMY||
19434
1/2
✓ Branch 0 taken 86598 times.
✗ Branch 1 not taken.
86598 ispitfall(x+8,y+8)||
19435
2/2
✓ Branch 0 taken 86592 times.
✓ Branch 1 taken 6 times.
86598 MAPFLAG(x+8,y+8)==mfNOENEMY||
19436 86592 MAPCOMBOFLAG(x+8,y+8)==mfNOENEMY
19437 )
19438 )
19439 {
19440 18 return false;
19441 }
19442
19443 // Other off-limit combos
19444
6/6
✓ Branch 0 taken 566668 times.
✓ Branch 1 taken 103953 times.
✓ Branch 2 taken 480080 times.
✓ Branch 3 taken 86588 times.
✓ Branch 4 taken 263614 times.
✓ Branch 5 taken 216466 times.
1150701 if((!isflier(tmpscr->enemy[i])&& guysbuf[tmpscr->enemy[i]].family!=eeTEK &&
19445
2/2
✓ Branch 0 taken 268956 times.
✓ Branch 1 taken 211124 times.
480080 (_walkflag(x,y+8,2) || groundblocked(x+8,y+8,guysbuf[tmpscr->enemy[i]]))) &&
19446 480080 guysbuf[tmpscr->enemy[i]].family!=eeZORA)
19447 216466 return false;
19448
19449 // Don't ever generate enemies on these combos!
19450
4/4
✓ Branch 0 taken 453851 times.
✓ Branch 1 taken 304 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 453857 times.
454155 if(COMBOTYPE(x+8,y+8)==cARMOS||COMBOTYPE(x+8,y+8)==cBSGRAVE)
19451 310 return false;
19452
19453 //BS Dodongos need at least 2 spaces.
19454
4/4
✓ Branch 0 taken 1039 times.
✓ Branch 1 taken 452818 times.
✓ Branch 2 taken 1014 times.
✓ Branch 3 taken 25 times.
453857 if((guysbuf[tmpscr->enemy[i]].family==eeDONGO)&&(guysbuf[tmpscr->enemy[i]].attributes[9] ==1))
19455 {
19456
3/4
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 19 times.
25 if(((x<16) ||_walkflag(x-16,y+8, 2))&&
19457
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3 times.
6 ((x>224)||_walkflag(x+16,y+8, 2))&&
19458
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
6 ((y<16) ||_walkflag(x, y-8, 2))&&
19459 ((y>144)||_walkflag(x, y+24,2)))
19460 {
19461 return false;
19462 }
19463 19 }
19464
19465 453851 return true;
19466 1105225 }
19467
19468 159460 bool is_ceiling_pattern(int32_t i)
19469 {
19470
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 159440 times.
159460 return (i==pCEILING || i==pCEILINGR);
19471 }
19472
19473 5716 int32_t placeenemy(int32_t i)
19474 {
19475 5716 std::map<int32_t, int32_t> freeposcache;
19476 5716 int32_t frees = 0;
19477
19478
2/2
✓ Branch 0 taken 62876 times.
✓ Branch 1 taken 5716 times.
68592 for(int32_t y=0; y<176; y+=16)
19479 {
19480
2/2
✓ Branch 0 taken 1006016 times.
✓ Branch 1 taken 62876 times.
1068892 for(int32_t x=0; x<256; x+=16)
19481 {
19482
3/4
✓ Branch 0 taken 1006016 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 396120 times.
✓ Branch 3 taken 609896 times.
1006016 if(is_starting_pos(i,x,y,0))
19483 {
19484
1/2
✓ Branch 0 taken 396120 times.
✗ Branch 1 not taken.
396120 freeposcache[frees++] = (y&0xF0)+(x>>4);
19485 396120 }
19486 1006016 }
19487 62876 }
19488
19489
2/2
✓ Branch 0 taken 5705 times.
✓ Branch 1 taken 11 times.
5716 if(frees > 0)
19490
2/4
✓ Branch 0 taken 5705 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5705 times.
✗ Branch 3 not taken.
5705 return freeposcache[zc_oldrand()%frees];
19491
19492 11 return -1;
19493 5716 }
19494
19495 80541 void spawnEnemy(int& pos, int& clk, int& x, int& y, int& fastguys, int& i, int& guycnt, int& loadcnt)
19496 {
19497 80541 bool placed=false;
19498 80541 int32_t t=-1;
19499
19500 // First: enemy combo flags
19501
2/2
✓ Branch 0 taken 800186 times.
✓ Branch 1 taken 63447 times.
863633 for(int32_t sy=0; sy<176; sy+=16)
19502 {
19503
2/2
✓ Branch 0 taken 12675715 times.
✓ Branch 1 taken 783092 times.
13458807 for(int32_t sx=0; sx<256; sx+=16)
19504 {
19505 12675715 int32_t cflag = MAPFLAG(sx, sy);
19506 12675715 int32_t cflag_i = MAPCOMBOFLAG(sx, sy);
19507
19508
2/4
✓ Branch 0 taken 12675715 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12675715 times.
✗ Branch 3 not taken.
12675715 if(((cflag==mfENEMYALL)||(cflag_i==mfENEMYALL)) && (!placed))
19509 {
19510 if(!ok2add(tmpscr->enemy[i]))
19511 {
19512 if (loadcnt < 10 && tmpscr->enemy[i] > 0 && tmpscr->enemy[i] < MAXGUYS) ++loadcnt;
19513 }
19514 else
19515 {
19516 addenemy(sx,
19517 (is_ceiling_pattern(tmpscr->pattern) && isSideViewGravity()) ? -(150+50*guycnt) : sy,
19518 (is_ceiling_pattern(tmpscr->pattern) && !(isSideViewGravity())) ? 150+50*guycnt : 0,tmpscr->enemy[i],-15);
19519
19520 ++guycnt;
19521
19522 placed=true;
19523 goto placed_enemy;
19524 }
19525 }
19526
19527
4/4
✓ Branch 0 taken 12658572 times.
✓ Branch 1 taken 17143 times.
✓ Branch 2 taken 12658572 times.
✓ Branch 3 taken 17143 times.
12675715 else if(((cflag==mfENEMY0+i)||(cflag_i==mfENEMY0+i)) && (!placed))
19528 {
19529
2/2
✓ Branch 0 taken 49 times.
✓ Branch 1 taken 17094 times.
17143 if(!ok2add(tmpscr->enemy[i]))
19530 {
19531
4/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 37 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 12 times.
49 if (loadcnt < 10 && tmpscr->enemy[i] > 0 && tmpscr->enemy[i] < MAXGUYS) ++loadcnt;
19532 49 }
19533 else
19534 {
19535 34188 addenemy(sx,
19536
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 17093 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
17094 (is_ceiling_pattern(tmpscr->pattern) && isSideViewGravity()) ? -(150+50*guycnt) : sy,
19537
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 17093 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
17094 (is_ceiling_pattern(tmpscr->pattern) && !(isSideViewGravity())) ? 150+50*guycnt : 0,tmpscr->enemy[i],-15);
19538
19539 17094 ++guycnt;
19540
19541 17094 placed=true;
19542 17094 goto placed_enemy;
19543 }
19544 49 }
19545 12658621 }
19546 783092 }
19547
19548 // Next: enemy pattern
19549
6/8
✓ Branch 0 taken 4939 times.
✓ Branch 1 taken 58508 times.
✓ Branch 2 taken 57952 times.
✓ Branch 3 taken 5495 times.
✓ Branch 4 taken 57952 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 57952 times.
63447 if((tmpscr->pattern==pRANDOM || tmpscr->pattern==pCEILING) && !(isSideViewGravity()) && ((tmpscr->enemy[i]>0&&tmpscr->enemy[i]<MAXGUYS)))
19550 {
19551 57952 do
19552 {
19553
19554 // NES positions
19555 99430 pos%=9;
19556 99430 x=stx[loadside][pos];
19557 99430 y=sty[loadside][pos];
19558 99430 ++pos;
19559 99430 ++t;
19560
2/2
✓ Branch 0 taken 41478 times.
✓ Branch 1 taken 57952 times.
157382 }
19561
2/2
✓ Branch 0 taken 221 times.
✓ Branch 1 taken 99209 times.
99430 while((t< 20) && !is_starting_pos(i,x,y,t));
19562 57952 }
19563
19564
4/4
✓ Branch 0 taken 57952 times.
✓ Branch 1 taken 5495 times.
✓ Branch 2 taken 221 times.
✓ Branch 3 taken 57731 times.
63447 if(t<0 || t >= 20) // above enemy pattern failed
19565 {
19566 // Final chance: find a random position anywhere onscreen
19567 5716 int32_t randpos = placeenemy(i);
19568
19569
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 5705 times.
5716 if(randpos>-1)
19570 {
19571 5705 x=(randpos&15)<<4;
19572 5705 y= randpos&0xF0;
19573 5705 }
19574 else // All opportunities failed - abort
19575 {
19576 11 return;
19577 }
19578 5705 }
19579
19580 {
19581 63436 int32_t c=0;
19582 63436 c=clk;
19583
19584
2/2
✓ Branch 0 taken 9584 times.
✓ Branch 1 taken 53852 times.
63436 if(!slowguy(tmpscr->enemy[i]))
19585 53852 ++fastguys;
19586
2/2
✓ Branch 0 taken 1586 times.
✓ Branch 1 taken 7998 times.
9584 else if(fastguys>0)
19587 1586 c=-15*(i-fastguys+2);
19588 else
19589 7998 c=-15*(i+1);
19590
19591
4/6
✓ Branch 0 taken 28859 times.
✓ Branch 1 taken 34577 times.
✓ Branch 2 taken 28859 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 28859 times.
63436 if(BSZ&&((tmpscr->enemy[i]>0&&tmpscr->enemy[i]<MAXGUYS))) // Hackish fix for crash in Waterford.qst on screen 0x65 of dmap 0 (map 1).
19592 {
19593 // Special case for blue leevers
19594
4/4
✓ Branch 0 taken 1894 times.
✓ Branch 1 taken 26965 times.
✓ Branch 2 taken 761 times.
✓ Branch 3 taken 1133 times.
28859 if(guysbuf[tmpscr->enemy[i]].family==eeLEV && guysbuf[tmpscr->enemy[i]].attributes[0]==1)
19595 761 c=-15*(i+1);
19596 else
19597 28098 c=-15;
19598 28859 }
19599
19600
2/2
✓ Branch 0 taken 62636 times.
✓ Branch 1 taken 800 times.
63436 if(!ok2add(tmpscr->enemy[i]))
19601 {
19602
4/6
✓ Branch 0 taken 130 times.
✓ Branch 1 taken 670 times.
✓ Branch 2 taken 130 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 130 times.
800 if (loadcnt < 10 && tmpscr->enemy[i] > 0 && tmpscr->enemy[i] < MAXGUYS) ++loadcnt;
19603 800 }
19604 else
19605 {
19606
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 62636 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
62636 if(((tmpscr->enemy[i]>0||tmpscr->enemy[i]<MAXGUYS))) // Hackish fix for crash in Waterford.qst on screen 0x65 of dmap 0 (map 1).
19607 {
19608
3/4
✓ Branch 0 taken 130 times.
✓ Branch 1 taken 62506 times.
✓ Branch 2 taken 130 times.
✗ Branch 3 not taken.
125272 addenemy(x,(is_ceiling_pattern(tmpscr->pattern) && isSideViewGravity()) ? -(150+50*guycnt) : y,
19609
3/4
✓ Branch 0 taken 130 times.
✓ Branch 1 taken 62506 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 130 times.
62636 (is_ceiling_pattern(tmpscr->pattern) && !(isSideViewGravity())) ? 150+50*guycnt : 0,tmpscr->enemy[i],c);
19610
19611 62636 ++guycnt;
19612 62636 }
19613 }
19614
19615 63436 placed=true;
19616 63436 } // if(t < 20)
19617
19618 placed_enemy:
19619
19620 // I don't like this, but it seems to work...
19621 static bool foundCarrier;
19622
19623
2/2
✓ Branch 0 taken 59157 times.
✓ Branch 1 taken 21373 times.
80530 if(i==0)
19624 21373 foundCarrier=false;
19625
19626
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80530 times.
80530 if(placed)
19627 {
19628
4/4
✓ Branch 0 taken 21373 times.
✓ Branch 1 taken 59157 times.
✓ Branch 2 taken 21204 times.
✓ Branch 3 taken 169 times.
80530 if(i==0 && tmpscr->enemyflags&efLEADER)
19629 {
19630 169 int32_t index = guys.idFirst(tmpscr->enemy[i],0xFFF);
19631
19632
2/2
✓ Branch 0 taken 162 times.
✓ Branch 1 taken 7 times.
169 if(index!=-1)
19633 {
19634 //grab the first segment. Not accurate to how older versions did it, but the way they did it might be incompatible with enemy editor.
19635
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 162 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
162 if ((((enemy*)guys.spr(index))->family == eeLANM) && !get_qr(qr_NO_LANMOLA_RINGLEADER)) index = guys.idNth(tmpscr->enemy[i], 2, 0xFFF);
19636
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 162 times.
162 if(index!=-1)
19637 {
19638 162 ((enemy*)guys.spr(index))->leader = true;
19639 162 }
19640 162 }
19641 169 }
19642
19643
4/4
✓ Branch 0 taken 80307 times.
✓ Branch 1 taken 223 times.
✓ Branch 2 taken 80243 times.
✓ Branch 3 taken 64 times.
80530 if(!foundCarrier && hasitem&(4|2))
19644 {
19645 64 int32_t index = guys.idFirst(tmpscr->enemy[i],0xFFF);
19646
19647
2/4
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 64 times.
64 if(index!=-1 && (((enemy*)guys.spr(index))->flags&guy_doesnt_count)==0)
19648 {
19649 64 ((enemy*)guys.spr(index))->itemguy = true;
19650 64 foundCarrier=true;
19651 64 }
19652 64 }
19653 80530 }
19654 80541 }
19655
19656 bool scriptloadenemies()
19657 {
19658 loaded_enemies = true;
19659 if(script_sle || sle_clk) return false;
19660 if(tmpscr->pattern==pNOSPAWN) return false;
19661
19662 if(tmpscr->pattern==pSIDES || tmpscr->pattern==pSIDESR)
19663 {
19664 script_side_load_enemies();
19665 return true;
19666 }
19667
19668 int32_t pos=zc_oldrand()%9;
19669 int32_t clk=-15,x=0,y=0,fastguys=0;
19670 int32_t i=0,guycnt=0;
19671 int32_t loadcnt = 10;
19672
19673 for(; i<loadcnt && tmpscr->enemy[i]>0; i++)
19674 {
19675 int32_t preguycount = guys.Count(); //I'm not experienced enough to know if this is an awful hack but it feels like one.
19676 spawnEnemy(pos, clk, x, y, fastguys, i, guycnt, loadcnt);
19677 if (guys.Count() > preguycount)
19678 {
19679 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
19680 {
19681 if (!FFCore.system_suspend[susptNPCSCRIPTS])
19682 {
19683 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
19684 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
19685 }
19686 }
19687 }
19688 --clk;
19689 }
19690 return true;
19691 }
19692
19693 14119527 void loadenemies()
19694 {
19695
3/4
✓ Branch 0 taken 14119527 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 53760 times.
✓ Branch 3 taken 14065767 times.
14119527 if(script_sle || sle_clk)
19696 {
19697 53760 side_load_enemies();
19698 53760 return;
19699 }
19700
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14065767 times.
14065767 if(tmpscr->pattern==pNOSPAWN) return;
19701
2/2
✓ Branch 0 taken 14030758 times.
✓ Branch 1 taken 35009 times.
14065767 if(loaded_enemies)
19702 14030758 return;
19703
19704 // check if it's the dungeon boss and it has been beaten before
19705
4/4
✓ Branch 0 taken 359 times.
✓ Branch 1 taken 34650 times.
✓ Branch 2 taken 269 times.
✓ Branch 3 taken 90 times.
35009 if(tmpscr->enemyflags&efBOSS && game->lvlitems[dlevel]&liBOSS)
19706 {
19707 90 loaded_enemies = true;
19708 90 return;
19709 }
19710
19711
4/4
✓ Branch 0 taken 34478 times.
✓ Branch 1 taken 441 times.
✓ Branch 2 taken 241 times.
✓ Branch 3 taken 34237 times.
34919 if(tmpscr->pattern==pSIDES || tmpscr->pattern==pSIDESR)
19712 {
19713 682 side_load_enemies();
19714 682 return;
19715 }
19716
19717 34237 loaded_enemies=true;
19718
19719 // do enemies that are always loaded
19720 34237 load_default_enemies();
19721
19722 // dungeon basements
19723
19724 static byte dngn_enemy_x[4] = {32,96,144,208};
19725
19726
2/2
✓ Branch 0 taken 904 times.
✓ Branch 1 taken 33333 times.
34237 if(currscr>=128)
19727 {
19728
2/2
✓ Branch 0 taken 429 times.
✓ Branch 1 taken 475 times.
904 if(DMaps[currdmap].flags&dmfCAVES) return;
19729
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 475 times.
475 if ( DMaps[currdmap].flags&dmfNEWCELLARENEMIES )
19730 {
19731 for(int32_t i=0; i<10; i++)
19732 {
19733 if ( tmpscr->enemy[i] )
19734 {
19735 int32_t preguycount = guys.Count();
19736 addenemy(dngn_enemy_x[i],96,tmpscr->enemy[i],-14-i);
19737 if (guys.Count() > preguycount)
19738 {
19739 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
19740 {
19741 if (!FFCore.system_suspend[susptNPCSCRIPTS])
19742 {
19743 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
19744 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
19745 }
19746 }
19747 }
19748 }
19749 }
19750 }
19751 else
19752 {
19753
2/2
✓ Branch 0 taken 1900 times.
✓ Branch 1 taken 475 times.
2375 for(int32_t i=0; i<4; i++)
19754 {
19755 1900 int32_t preguycount = guys.Count();
19756
2/2
✓ Branch 0 taken 1044 times.
✓ Branch 1 taken 856 times.
1900 addenemy(dngn_enemy_x[i],96,tmpscr->enemy[i]?tmpscr->enemy[i]:(int32_t)eKEESE1,-14-i);
19757
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1900 times.
1900 if (guys.Count() > preguycount)
19758 {
19759
2/2
✓ Branch 0 taken 1896 times.
✓ Branch 1 taken 4 times.
1900 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
19760 {
19761
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (!FFCore.system_suspend[susptNPCSCRIPTS])
19762 {
19763 4 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
19764 4 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
19765 4 }
19766 4 }
19767 1900 }
19768 1900 }
19769 }
19770 475 return;
19771 }
19772
19773 // check if it's been long enough to reload all enemies
19774
19775 33333 int32_t loadcnt = 10;
19776 33333 int16_t s = (currmap<<7)+currscr;
19777 33333 bool beenhere = false;
19778 33333 bool reload = true;
19779 33333 bool unbeatablereload = true;
19780
19781
2/2
✓ Branch 0 taken 199998 times.
✓ Branch 1 taken 33333 times.
233331 for(int32_t i=0; i<6; i++)
19782
2/2
✓ Branch 0 taken 190832 times.
✓ Branch 1 taken 9166 times.
209164 if(visited[i]==s)
19783 9166 beenhere = true;
19784
19785
2/2
✓ Branch 0 taken 9166 times.
✓ Branch 1 taken 24167 times.
33333 if(!beenhere) //Okay so this basically checks the last 6 unique screen's you've been in and checks if the current screen is one of them.
19786 {
19787 24167 visited[vhead]=s; //If not, it adds it to the array,
19788 24167 vhead = (vhead+1)%6; //which overrides one of the others, and then moves onto the next.
19789 24167 }
19790
2/2
✓ Branch 0 taken 4611 times.
✓ Branch 1 taken 4555 times.
9166 else if(game->guys[s]==0) //Then, if you have been here, and the number of enemies left on the screen is 0,
19791 {
19792 4555 loadcnt = 0; //It will tell it not to load any enemies,
19793 4555 reload = false; //both by setting loadcnt to 0 and making the reload if statement not run.
19794 4555 }
19795
19796
2/2
✓ Branch 0 taken 4555 times.
✓ Branch 1 taken 28778 times.
33333 if(reload) //This if statement is only false if this screen is one of the last 6 screens you visited and you left 0 enemies alive.
19797 {
19798 28778 loadcnt = game->guys[s]; //Otherwise, if this if statement is true, it will try to load the last amount of enemies you left alive.
19799
19800
2/4
✓ Branch 0 taken 10143 times.
✓ Branch 1 taken 18635 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
28778 if(loadcnt==0 || //Then, if the number of enemies is 0, that means you left 0 enemies alive on a screen but haven't been there in the past 6 screens.
19801
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10143 times.
10143 (get_qr(qr_NO_LEAVE_ONE_ENEMY_ALIVE_TRICK) && !beenhere)) //Alternatively, if you have the quest rule enabled that always respawns all enemies after a period of time, and you haven't been here in 6 screens.
19802 18635 loadcnt = 10; //That means all enemies need to be respawned.
19803
3/4
✓ Branch 0 taken 24167 times.
✓ Branch 1 taken 4611 times.
✓ Branch 2 taken 24167 times.
✗ Branch 3 not taken.
28778 if (!beenhere && get_qr(qr_UNBEATABLES_DONT_KEEP_DEAD))
19804 {
19805 for(int32_t i = 0; i<loadcnt && tmpscr->enemy[i]>0; i++)
19806 {
19807 if (!(guysbuf[tmpscr->enemy[i]].flags & guy_doesnt_count))
19808 {
19809 unbeatablereload = false;
19810 }
19811 }
19812 if (unbeatablereload)
19813 {
19814 loadcnt = 10;
19815 }
19816 }
19817 28778 }
19818
19819
4/4
✓ Branch 0 taken 31874 times.
✓ Branch 1 taken 1459 times.
✓ Branch 2 taken 187 times.
✓ Branch 3 taken 31687 times.
33333 if((get_qr(qr_ALWAYSRET)) || (tmpscr->flags3&fENEMIESRETURN)) //If enemies always return is enabled quest-wide or for this screen,
19820 1646 loadcnt = 10; //All enemies also need to be respawned.
19821
19822 33333 int32_t pos=zc_oldrand()%9; //This sets up a variable for spawnEnemy to edit so as to spawn the enemies pseudo-randomly.
19823 33333 int32_t clk=-15,x=0,y=0,fastguys=0; //clk being negative means the enemy is in its spawn poof.
19824 33333 int32_t i=0,guycnt=0; //Lastly, resets guycnt to 0 so spawnEnemy can increment it manually per-enemy.
19825
19826
4/4
✓ Branch 0 taken 14555 times.
✓ Branch 1 taken 99319 times.
✓ Branch 2 taken 80541 times.
✓ Branch 3 taken 33333 times.
113874 for(; i<loadcnt && tmpscr->enemy[i]>0; i++)
19827 {
19828 80541 int32_t preguycount = guys.Count(); //I'm not experienced enough to know if this is an awful hack but it feels like one.
19829 80541 spawnEnemy(pos, clk, x, y, fastguys, i, guycnt, loadcnt);
19830
2/2
✓ Branch 0 taken 811 times.
✓ Branch 1 taken 79730 times.
80541 if (guys.Count() > preguycount)
19831 {
19832
2/2
✓ Branch 0 taken 77383 times.
✓ Branch 1 taken 2347 times.
79730 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
19833 {
19834
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2343 times.
2347 if (!FFCore.system_suspend[susptNPCSCRIPTS])
19835 {
19836 2343 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
19837 2343 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
19838 2343 }
19839 2347 }
19840 79730 }
19841
19842 80541 --clk; //Each additional enemy spawns with a slightly longer spawn poof than the previous.
19843 80541 }
19844
19845 33333 game->guys[s] = guycnt;
19846 //} //if(true)
19847 14119527 }
19848 233 void moneysign()
19849 {
19850 233 additem(48,108,iRupy,ipDUMMY);
19851 233 set_clip_state(pricesdisplaybuf, 0);
19852 233 textout_ex(pricesdisplaybuf,get_zc_font(font_zfont),"X",64,112,CSET(0)+1,-1);
19853 233 }
19854
19855 3272 void putprices(bool sign)
19856 {
19857
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 3243 times.
3272 if(fadeclk > 0) return;
19858
19859 3243 rectfill(pricesdisplaybuf, 72, 112, pricesdisplaybuf->w-1, pricesdisplaybuf->h-1, 0);
19860 3243 int32_t step=32;
19861 3243 int32_t x=80;
19862
19863
2/2
✓ Branch 0 taken 281 times.
✓ Branch 1 taken 2962 times.
3243 if(prices[2]==0)
19864 {
19865 2962 step<<=1;
19866
19867
2/2
✓ Branch 0 taken 2930 times.
✓ Branch 1 taken 32 times.
2962 if(prices[1]==0)
19868 {
19869 2930 x=112;
19870 2930 }
19871 2962 }
19872
19873
2/2
✓ Branch 0 taken 3243 times.
✓ Branch 1 taken 9729 times.
12972 for(int32_t i=0; i<3; i++)
19874 {
19875 // Kind of stupid, but it works: 100000 is used to indicate that an item
19876 // has a price of zero rather than there being no item.
19877 // 100000 isn't a valid price, so this doesn't cause problems.
19878
3/4
✓ Branch 0 taken 1039 times.
✓ Branch 1 taken 8690 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1039 times.
9729 if(prices[i]!=0 && prices[i]<100000)
19879 {
19880 char buf[8];
19881 1039 sprintf(buf,sign?"%+3d":"%3d",prices[i]);
19882
19883 1039 int32_t l=(int32_t)strlen(buf);
19884 1039 set_clip_state(pricesdisplaybuf, 0);
19885
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 1012 times.
1039 textout_ex(pricesdisplaybuf,get_zc_font(font_zfont),buf,x-(l>3?(l-3)<<3:0),112,CSET(0)+1,-1);
19886 1039 }
19887
19888 9729 x+=step;
19889 9729 }
19890 3272 }
19891
19892 // Setting up special rooms
19893 // Also called when the Letter is used successfully.
19894 1204 void setupscreen()
19895 {
19896 1204 boughtsomething=false;
19897 1204 int32_t t=currscr<128?0:1;
19898 1204 word str=tmpscr[t].str;
19899
19900 // Prices are already set to 0 in dowarp()
19901
14/15
✓ Branch 0 taken 174 times.
✓ Branch 1 taken 685 times.
✓ Branch 2 taken 162 times.
✓ Branch 3 taken 28 times.
✓ Branch 4 taken 44 times.
✓ Branch 5 taken 11 times.
✓ Branch 6 taken 13 times.
✓ Branch 7 taken 2 times.
✓ Branch 8 taken 2 times.
✓ Branch 9 taken 17 times.
✓ Branch 10 taken 32 times.
✓ Branch 11 taken 1 times.
✓ Branch 12 taken 19 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 14 times.
1204 switch(tmpscr[t].room)
19902 {
19903 case rSP_ITEM: // special item
19904 162 additem(120,89,tmpscr[t].catchall,ipONETIME2+ipHOLDUP+ipCHECK | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0));
19905 162 break;
19906
19907 case rINFO: // pay for info
19908 {
19909 28 int32_t count = 0;
19910 28 int32_t base = 88;
19911 28 int32_t step = 5;
19912
19913 28 moneysign();
19914
19915
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 84 times.
112 for(int32_t i=0; i<3; i++)
19916 {
19917
1/2
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
84 if(QMisc.info[tmpscr[t].catchall].str[i])
19918 {
19919 84 ++count;
19920 84 }
19921 else
19922 break;
19923 84 }
19924
19925
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28 times.
28 if(count)
19926 {
19927
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 if(count==1)
19928 {
19929 base = 88+32;
19930 }
19931
19932
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 if(count==2)
19933 {
19934 step = 6;
19935 }
19936
19937
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 28 times.
112 for(int32_t i=0; i < count; i++)
19938 {
19939 84 additem((i << step)+base, 89, iRupy, ipMONEY + ipDUMMY);
19940 84 ((item*)items.spr(items.Count()-1))->PriceIndex = i;
19941 84 prices[i] = -(QMisc.info[tmpscr[t].catchall].price[i]);
19942
1/2
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
84 if(prices[i]==0)
19943 prices[i]=100000; // So putprices() knows there's an item here and positions the price correctly
19944 84 int32_t itemid = current_item_id(itype_wealthmedal);
19945
19946
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 84 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
84 if(itemid>=0 && prices[i]!=100000)
19947 {
19948 if(itemsbuf[itemid].flags & item_flag1)
19949 prices[i]=((prices[i]*itemsbuf[itemid].misc1)/100);
19950 else
19951 prices[i]-=itemsbuf[itemid].misc1;
19952 prices[i]=vbound(prices[i], -99999, 0);
19953 if(prices[i]==0)
19954 prices[i]=100000;
19955 }
19956
19957
2/6
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 84 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
84 if((QMisc.info[tmpscr[t].catchall].price[i])>1 && prices[i]>-1 && prices[i]!=100000)
19958 prices[i]=-1;
19959 84 }
19960 28 }
19961
19962 28 break;
19963 }
19964
19965 case rMONEY: // secret money
19966 44 additem(120,89,iRupy,ipONETIME+ipDUMMY+ipMONEY);
19967 44 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19968 44 break;
19969
19970 case rGAMBLE: // gambling
19971 11 prices[0]=prices[1]=prices[2]=-10;
19972 11 moneysign();
19973 11 additem(88,89,iRupy,ipMONEY+ipDUMMY);
19974 11 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19975 11 additem(120,89,iRupy,ipMONEY+ipDUMMY);
19976 11 ((item*)items.spr(items.Count()-1))->PriceIndex = 1;
19977 11 additem(152,89,iRupy,ipMONEY+ipDUMMY);
19978 11 ((item*)items.spr(items.Count()-1))->PriceIndex = 2;
19979 11 break;
19980
19981 case rREPAIR: // door repair
19982
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 setmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
19983 // }
19984 13 repaircharge=tmpscr[t].catchall;
19985 13 break;
19986
19987 case rMUPGRADE: // upgrade magic
19988 2 adjustmagic=true;
19989 2 break;
19990
19991 case rLEARNSLASH: // learn slash attack
19992 2 learnslash=true;
19993 2 break;
19994
19995 case rRP_HC: // heart container or red potion
19996 17 additem(88,89,iRPotion,ipONETIME2+ipHOLDUP+ipFADE);
19997 17 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19998 17 additem(152,89,iHeartC,ipONETIME2+ipHOLDUP+ipFADE);
19999 17 ((item*)items.spr(items.Count()-1))->PriceIndex = 1;
20000 17 break;
20001
20002 case rP_SHOP: // potion shop
20003
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 20 times.
32 if(current_item(itype_letter)<i_letter_used)
20004 {
20005 12 str=0;
20006 12 break;
20007 }
20008
20009 [[fallthrough]];
20010 case rTAKEONE: // take one
20011 case rSHOP: // shop
20012 {
20013 194 int32_t count = 0;
20014 194 int32_t base = 88;
20015 194 int32_t step = 5;
20016
20017
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 193 times.
194 if(tmpscr[t].room != rTAKEONE)
20018 193 moneysign();
20019
20020 //count and align the stuff
20021
2/2
✓ Branch 0 taken 157 times.
✓ Branch 1 taken 560 times.
717 for(int32_t i=0; i<3; ++i)
20022 {
20023
2/2
✓ Branch 0 taken 523 times.
✓ Branch 1 taken 37 times.
560 if(QMisc.shop[tmpscr[t].catchall].hasitem[count] != 0)
20024 {
20025 523 ++count;
20026 523 }
20027 else
20028 {
20029 37 break;
20030 }
20031 523 }
20032
20033
2/2
✓ Branch 0 taken 172 times.
✓ Branch 1 taken 22 times.
194 if(count==1)
20034 {
20035 22 base = 88+32;
20036 22 }
20037
20038
2/2
✓ Branch 0 taken 179 times.
✓ Branch 1 taken 15 times.
194 if(count==2)
20039 {
20040 15 step = 6;
20041 15 }
20042
20043
2/2
✓ Branch 0 taken 523 times.
✓ Branch 1 taken 194 times.
717 for(int32_t i=0; i<count; i++)
20044 {
20045 523 additem((i<<step)+base, 89, QMisc.shop[tmpscr[t].catchall].item[i], ipHOLDUP+ipFADE+(tmpscr[t].room == rTAKEONE ? ipONETIME2 : ipCHECK));
20046 523 ((item*)items.spr(items.Count()-1))->PriceIndex = i;
20047
20048
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 521 times.
523 if(tmpscr[t].room != rTAKEONE)
20049 {
20050 521 prices[i] = QMisc.shop[tmpscr[t].catchall].price[i];
20051
1/2
✓ Branch 0 taken 521 times.
✗ Branch 1 not taken.
521 if(prices[i]==0)
20052 prices[i]=100000; // So putprices() knows there's an item here and positions the price correctly
20053 521 int32_t itemid = current_item_id(itype_wealthmedal);
20054
20055
3/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 512 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
521 if(itemid>=0 && prices[i]!=100000)
20056 {
20057
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(itemsbuf[itemid].flags & item_flag1)
20058 9 prices[i]=((prices[i]*itemsbuf[itemid].misc1) / 100);
20059 else
20060 prices[i]+=itemsbuf[itemid].misc1;
20061 9 prices[i]=vbound(prices[i], 0, 99999);
20062
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(prices[i]==0)
20063 prices[i]=100000;
20064 9 }
20065
20066
2/4
✓ Branch 0 taken 521 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 521 times.
✗ Branch 3 not taken.
521 if((QMisc.shop[tmpscr[t].catchall].price[i])>1 && prices[i]<1)
20067 prices[i]=1;
20068 521 }
20069 523 }
20070
20071 194 break;
20072 }
20073 case rBOTTLESHOP: // bottle shop
20074 {
20075 1 int32_t count = 0;
20076 1 int32_t base = 88;
20077 1 int32_t step = 5;
20078
20079 1 moneysign();
20080 1 bottleshoptype const& bst = QMisc.bottle_shop_types[tmpscr[t].catchall];
20081 //count and align the stuff
20082
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 3 times.
4 for(int32_t i=0; i<3; ++i)
20083 {
20084
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(bst.fill[count] != 0)
20085 {
20086 3 ++count;
20087 3 }
20088 else
20089 {
20090 break;
20091 }
20092 3 }
20093
20094
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(count==1)
20095 {
20096 base = 88+32;
20097 }
20098
20099
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(count==2)
20100 {
20101 step = 6;
20102 }
20103
20104
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 times.
4 for(int32_t i=0; i<count; i++)
20105 {
20106 3 adddummyitem((i<<step)+base, 89, /*Use item 0 as a dummy...*/0, ipHOLDUP+ipFADE+ipCHECK);
20107 //{ Setup dummy item
20108 3 item* curItem = ((item*)items.spr(items.Count()-1));
20109 3 curItem->PriceIndex = i;
20110 3 newcombo const& cmb = combobuf[bst.comb[i]];
20111 3 curItem->o_tile = cmb.o_tile;
20112 3 curItem->o_cset = bst.cset[i];
20113 3 curItem->cs = curItem->o_cset;
20114 3 curItem->tile = cmb.o_tile;
20115 3 curItem->o_speed = cmb.speed;
20116 3 curItem->o_delay = 0;
20117 3 curItem->frames = cmb.frames;
20118 3 curItem->flip = cmb.flip;
20119 3 curItem->family = itype_bottlefill; //no pickup w/o empty bottle
20120 3 curItem->pstring = 0;
20121 3 curItem->pickup = ipHOLDUP+ipFADE+ipCHECK;
20122 3 curItem->flash = false;
20123 3 curItem->twohand = false;
20124 3 curItem->anim = true;
20125 3 curItem->hit_width=1;
20126 3 curItem->hyofs=4;
20127 3 curItem->hit_height=12;
20128 3 curItem->script=0;
20129 3 curItem->txsz=1;
20130 3 curItem->tysz=1;
20131 //}
20132
20133 3 prices[i] = bst.price[i];
20134
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(prices[i]==0)
20135 prices[i]=100000; // So putprices() knows there's an item here and positions the price correctly
20136 3 int32_t itemid = current_item_id(itype_wealthmedal);
20137
20138
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if(itemid>=0 && prices[i]!=100000)
20139 {
20140 if(itemsbuf[itemid].flags & item_flag1)
20141 prices[i]=((prices[i]*itemsbuf[itemid].misc1)/100);
20142 else
20143 prices[i]+=itemsbuf[itemid].misc1;
20144 prices[i]=vbound(prices[i], 0, 99999);
20145 if(prices[i]==0)
20146 prices[i]=100000;
20147 }
20148
20149
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if((bst.price[i])>1 && prices[i]<1)
20150 prices[i]=1;
20151 3 }
20152
20153 1 break;
20154 }
20155
20156 case rBOMBS: // more bombs
20157 19 additem(120,89,iRupy,ipDUMMY+ipMONEY);
20158 19 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
20159 19 prices[0]=-tmpscr[t].catchall;
20160 19 break;
20161
20162 case rARROWS: // more arrows
20163 additem(120,89,iRupy,ipDUMMY+ipMONEY);
20164 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
20165 prices[0]=-tmpscr[t].catchall;
20166 break;
20167
20168 case rSWINDLE: // leave heart container or money
20169 14 additem(88,89,iHeartC,ipDUMMY+ipMONEY);
20170 14 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
20171 14 prices[0]=-1;
20172 14 additem(152,89,iRupy,ipDUMMY+ipMONEY);
20173 14 ((item*)items.spr(items.Count()-1))->PriceIndex = 1;
20174 14 prices[1]=-tmpscr[t].catchall;
20175 14 break;
20176
20177 }
20178
20179
3/4
✓ Branch 0 taken 1185 times.
✓ Branch 1 taken 19 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1185 times.
1204 if(tmpscr[t].room == rBOMBS || tmpscr[t].room == rARROWS)
20180 {
20181 19 int32_t i = (tmpscr[t].room == rSWINDLE ? 1 : 0);
20182 19 int32_t itemid = current_item_id(itype_wealthmedal);
20183
20184
1/2
✓ Branch 0 taken 19 times.
✗ Branch 1 not taken.
19 if(itemid >= 0)
20185 {
20186 if(itemsbuf[itemid].flags & item_flag1)
20187 prices[i]*=(itemsbuf[itemid].misc1 /100.0);
20188 else
20189 prices[i]+=itemsbuf[itemid].misc1;
20190 }
20191
20192
2/4
✓ Branch 0 taken 19 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 19 times.
✗ Branch 3 not taken.
19 if(tmpscr[t].catchall>1 && prices[i]>-1)
20193 prices[i]=-1;
20194 19 }
20195
20196 1204 putprices(false);
20197
20198
2/2
✓ Branch 0 taken 1145 times.
✓ Branch 1 taken 59 times.
1204 if(str)
20199 {
20200 1145 donewmsg(str);
20201 1145 }
20202 else
20203 {
20204 59 Hero.unfreeze();
20205 }
20206 1204 }
20207
20208 // Increments msgptr and returns the control code argument pointed at.
20209 3723 word grab_next_argument()
20210 {
20211
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3723 times.
3723 if(unsigned(msgptr+1)>=MsgStrings[msgstr].s.size()) return 0;
20212 3723 byte val=MsgStrings[msgstr].s[++msgptr]-1;
20213 3723 word ret=val;
20214
20215 // If an argument is succeeded by 255, then it's a three-byte argument -
20216 // between 254 and 65535 (or whatever the maximum actually is)
20217
2/2
✓ Branch 0 taken 3589 times.
✓ Branch 1 taken 109 times.
3723 if((unsigned(msgptr+2)<MsgStrings[msgstr].s.size())
20218
2/2
✓ Branch 0 taken 3698 times.
✓ Branch 1 taken 25 times.
3723 && uint8_t(MsgStrings[msgstr].s[msgptr+1]) == 255)
20219 {
20220 109 val=MsgStrings[msgstr].s[msgptr+2];
20221 109 word next=val;
20222 109 ret += 254*next;
20223 109 msgptr+=2;
20224 109 }
20225
20226 3723 return ret;
20227 3723 }
20228
20229 enum
20230 {
20231 MNU_CURSOR_TILE, MNU_CURSOR_CSET,
20232 MNU_CURSOR_WID, MNU_CURSOR_HEI, MNU_CURSOR_FLIP,
20233
20234 MNU_CHOSEN, MNU_TIMER, MNU_CAN_CONFIRM,
20235
20236 MNU_DATA_MAX
20237 };
20238 struct menu_choice
20239 {
20240 int32_t x, y;
20241 int32_t pos;
20242 int32_t upos, dpos, lpos, rpos;
20243 8 menu_choice() : x(0), y(0), pos(0), upos(0), dpos(0), lpos(0), rpos(0)
20244 8 {}
20245 8 menu_choice(int32_t x, int32_t y, int32_t pos, int32_t upos,
20246 int32_t dpos, int32_t lpos, int32_t rpos)
20247 8 : x(x), y(y), pos(pos), upos(upos), dpos(dpos), lpos(lpos), rpos(rpos)
20248 8 {}
20249 };
20250 static int32_t msg_menu_data[MNU_DATA_MAX];
20251 static bool do_run_menu = false;
20252 bool do_end_str = false;
20253 static bool wait_advance = false;
20254 336 static std::map<int32_t, menu_choice> menu_options;
20255 43139 void clr_msg_data()
20256 {
20257 43139 do_end_str = false;
20258 43139 wait_advance = false;
20259 43139 do_run_menu = false;
20260 43139 menu_options.clear();
20261 43139 memset(msg_menu_data, 0, sizeof(msg_menu_data));
20262 43139 }
20263
20264 static bool doing_name_insert = false;
20265 static char namebuf[9] = {0};
20266 static char* nameptr = NULL;
20267 static int32_t ssc_tile_hei = -1, ssc_tile_hei_buf = -1;
20268 965 bool runMenuCursor()
20269 {
20270 965 clear_bitmap(msg_menu_bmp_buf);
20271
1/2
✓ Branch 0 taken 965 times.
✗ Branch 1 not taken.
965 if(!menu_options.size())
20272 {
20273 msg_menu_data[MNU_CHOSEN] = 0;
20274 return true; //end menu
20275 }
20276 965 int32_t pos = msg_menu_data[MNU_CHOSEN];
20277 //If the cursor is at an invalid pos, find the first pos >= 0...
20278
1/2
✓ Branch 0 taken 965 times.
✗ Branch 1 not taken.
965 if(menu_options.find(pos) == menu_options.end())
20279 {
20280 pos = 0;
20281 while(menu_options.find(pos) == menu_options.end())
20282 ++pos;
20283 }
20284 965 menu_choice* ch = &menu_options[pos];
20285
20286 965 bool pressed = true;
20287
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 964 times.
965 if(rUp()) pos = ch->upos;
20288
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 962 times.
964 else if(rDown()) pos = ch->dpos;
20289
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 962 times.
962 else if(rLeft()) pos = ch->lpos;
20290
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 962 times.
962 else if(rRight()) pos = ch->rpos;
20291 962 else pressed = false;
20292
20293
2/2
✓ Branch 0 taken 962 times.
✓ Branch 1 taken 3 times.
965 if(pressed)
20294 3 msg_menu_data[MNU_TIMER] = 1;
20295
20296 965 bool hold_input = !((msg_menu_data[MNU_TIMER]++) % 20);
20297 965 bool held = false;
20298
2/2
✓ Branch 0 taken 917 times.
✓ Branch 1 taken 48 times.
965 if(hold_input)
20299 {
20300 48 held = true;
20301
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if(Up()) pos = ch->upos;
20302
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 else if(Down()) pos = ch->dpos;
20303
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 else if(Left()) pos = ch->lpos;
20304
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 else if(Right()) pos = ch->rpos;
20305 48 else held = false;
20306 48 }
20307 //If the cursor is at an invalid pos, find the first pos >= 0...
20308
1/2
✓ Branch 0 taken 965 times.
✗ Branch 1 not taken.
965 if(menu_options.find(pos) == menu_options.end())
20309 {
20310 pos = 0;
20311 while(menu_options.find(pos) == menu_options.end())
20312 ++pos;
20313 }
20314
4/4
✓ Branch 0 taken 962 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 962 times.
✓ Branch 3 taken 3 times.
965 if((pressed || held) && pos != msg_menu_data[MNU_CHOSEN])
20315 3 sfx(MsgStrings[msgstr].sfx);
20316
20317 965 ch = &menu_options[pos];
20318 1930 overtileblock16(msg_menu_bmp_buf, msg_menu_data[MNU_CURSOR_TILE],
20319 965 ch->x, ch->y, (int32_t)ceil(msg_menu_data[MNU_CURSOR_WID]/16.0),
20320 965 (int32_t)ceil(msg_menu_data[MNU_CURSOR_HEI]/16.0),
20321 965 msg_menu_data[MNU_CURSOR_CSET], msg_menu_data[MNU_CURSOR_FLIP]);
20322
20323 965 msg_menu_data[MNU_CHOSEN] = pos;
20324
20325
2/2
✓ Branch 0 taken 941 times.
✓ Branch 1 taken 24 times.
965 if(!msg_menu_data[MNU_CAN_CONFIRM]) //Prevent instantly accepting when holding A
20326 {
20327 24 rAbtn(); //Eat
20328
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 2 times.
24 if(!cAbtn()) msg_menu_data[MNU_CAN_CONFIRM] = 1;
20329 24 }
20330
20331
3/4
✓ Branch 0 taken 962 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 962 times.
965 bool ret = (pressed || held) ? false : rAbtn();
20332 //Eat inputs
20333 965 rUp(); rDown(); rLeft(); rRight(); rAbtn();
20334
20335
2/2
✓ Branch 0 taken 963 times.
✓ Branch 1 taken 2 times.
965 if(ret)
20336 2 menu_options.clear();
20337
20338 965 return ret;
20339 //false if pos changed this frame; no confirming while moving the cursor!
20340 965 }
20341
20342 683498 bool bottom_margin_clip()
20343 {
20344 724729 return !get_qr(qr_OLD_STRING_EDITOR_MARGINS)
20345
2/2
✓ Branch 0 taken 642267 times.
✓ Branch 1 taken 41231 times.
683498 && cursor_y >= (msg_h + (get_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT)?16:0) - msg_margins[down]);
20346 }
20347
20348 void update_msgstr();
20349 244846 bool parsemsgcode()
20350 {
20351
2/2
✓ Branch 0 taken 2722 times.
✓ Branch 1 taken 242124 times.
244846 if(msgptr>=MsgStrings[msgstr].s.size()) return false;
20352 242124 byte c = byte(MsgStrings[msgstr].s[msgptr]-1);
20353
19/39
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 238927 times.
✓ Branch 2 taken 1278 times.
✓ Branch 3 taken 1605 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 39 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 times.
✓ Branch 9 taken 4 times.
✓ Branch 10 taken 68 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 9 times.
✓ Branch 14 taken 21 times.
✓ Branch 15 taken 7 times.
✓ Branch 16 taken 6 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✓ Branch 24 taken 122 times.
✓ Branch 25 taken 17 times.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✓ Branch 29 taken 2 times.
✓ Branch 30 taken 8 times.
✓ Branch 31 taken 2 times.
✓ Branch 32 taken 4 times.
✓ Branch 33 taken 1 times.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
242124 switch(c)
20354 {
20355 case MSGC_NEWLINE:
20356 {
20357 1278 ssc_tile_hei = ssc_tile_hei_buf;
20358
1/2
✓ Branch 0 taken 1278 times.
✗ Branch 1 not taken.
1278 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20359 1278 ssc_tile_hei_buf = -1;
20360 1278 cursor_y += thei + MsgStrings[msgstr].vspace;
20361 1278 cursor_x=msg_margins[left];
20362 1278 return true;
20363 }
20364
20365 case MSGC_COLOUR:
20366 {
20367 1605 int32_t cset = (grab_next_argument());
20368 1605 msgcolour = CSET(cset)+(grab_next_argument());
20369 1605 return true;
20370 }
20371
20372 case MSGC_SHDCOLOR:
20373 {
20374 int32_t cset = (grab_next_argument());
20375 msg_shdcol = CSET(cset)+(grab_next_argument());
20376 return true;
20377 }
20378 case MSGC_SHDTYPE:
20379 {
20380 msg_shdtype = grab_next_argument();
20381 return true;
20382 }
20383
20384 case MSGC_SPEED:
20385 {
20386 39 msgspeed=grab_next_argument();
20387 39 return true;
20388 }
20389
20390 case MSGC_CTRUP:
20391 {
20392 int32_t a1 = grab_next_argument();
20393 int32_t a2 = grab_next_argument();
20394 game->change_counter(a2, a1);
20395 return true;
20396 }
20397
20398 case MSGC_CTRDN:
20399 {
20400 2 int32_t a1 = grab_next_argument();
20401 2 int32_t a2 = grab_next_argument();
20402 2 game->change_counter(-a2, a1);
20403 2 return true;
20404 }
20405
20406 case MSGC_CTRSET:
20407 {
20408 4 int32_t a1 = grab_next_argument();
20409 4 int32_t a2 = grab_next_argument();
20410 4 game->set_counter(vbound(a2, 0, game->get_maxcounter(a1)), a1);
20411 4 return true;
20412 }
20413
20414 case MSGC_CTRUPPC:
20415 case MSGC_CTRDNPC:
20416 case MSGC_CTRSETPC:
20417 {
20418 2 int32_t code = MsgStrings[msgstr].s[msgptr]-1;
20419 2 int32_t counter = grab_next_argument();
20420 2 int32_t amount = grab_next_argument();
20421 2 amount = int32_t(vbound(amount*0.01, 0.0, 1.0)*game->get_maxcounter(counter));
20422
20423
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(code==MSGC_CTRDNPC)
20424 amount*=-1;
20425
20426
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(code==MSGC_CTRSETPC)
20427 game->set_counter(amount, counter);
20428 else
20429 2 game->change_counter(amount, counter);
20430
20431 2 return true;
20432 }
20433
20434 case MSGC_GIVEITEM:
20435 {
20436 68 int32_t itemID = grab_next_argument();
20437
20438 68 getitem(itemID, true);
20439
2/4
✓ Branch 0 taken 68 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 68 times.
68 if ( !FFCore.doscript(ScriptType::Item, itemID) && (((unsigned)itemID) < 256) )
20440 {
20441 68 FFCore.reset_script_engine_data(ScriptType::Item, itemID);
20442 68 FFCore.doscript(ScriptType::Item, itemID) = (itemsbuf[itemID].flags&item_passive_script) > 0;
20443 68 }
20444 68 return true;
20445 }
20446
20447
20448 case MSGC_WARP:
20449 {
20450 int32_t dmap = grab_next_argument();
20451 int32_t scrn = grab_next_argument();
20452 int32_t dx = grab_next_argument();
20453 int32_t dy = grab_next_argument();
20454 int32_t wfx = grab_next_argument();
20455 int32_t sfx = grab_next_argument();
20456 if(dx >= MAX_SCC_ARG) dx = -1;
20457 if(dy >= MAX_SCC_ARG) dy = -1;
20458 FFCore.warp_player(wtIWARP, dmap, scrn, dx, dy, wfx, sfx, 0, 0);
20459 do_end_str = true;
20460 return true;
20461 }
20462
20463 case MSGC_SETSCREEND:
20464 {
20465 int32_t dmap = (grab_next_argument()<<7); //dmap and screen may be transposed here.
20466 int32_t screen = grab_next_argument();
20467 int32_t reg = grab_next_argument();
20468 int32_t val = grab_next_argument();
20469 FFCore.set_screen_d(screen + dmap, reg, val);
20470 return true;
20471 }
20472 case MSGC_TAKEITEM:
20473 {
20474 9 int32_t itemID = grab_next_argument();
20475
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ( FFCore.doscript(ScriptType::Item, itemID) )
20476 {
20477 FFCore.doscript(ScriptType::Item, itemID) = 4; //Val of 4 means 'clear stack and quit'
20478 }
20479 9 takeitem(itemID);
20480
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ( game->forced_bwpn == itemID )
20481 {
20482 game->forced_bwpn = -1;
20483 } //not else if! -Z
20484
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ( game->forced_awpn == itemID )
20485 {
20486 game->forced_awpn = -1;
20487 }
20488
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ( game->forced_xwpn == itemID )
20489 {
20490 game->forced_xwpn = -1;
20491 } //not else if! -Z
20492
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ( game->forced_ywpn == itemID )
20493 {
20494 game->forced_ywpn = -1;
20495 }
20496 9 verifyBothWeapons();
20497 9 return true;
20498 }
20499
20500 case MSGC_SFX:
20501 {
20502 21 sfx((int32_t)grab_next_argument(),128);
20503 21 return true;
20504 }
20505
20506 case MSGC_MIDI:
20507 {
20508 7 int32_t music = (int32_t)(grab_next_argument());
20509
20510
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 1 times.
7 if(music==0)
20511 1 music_stop();
20512 else
20513 6 jukebox(music+(ZC_MIDI_COUNT-1));
20514
20515 7 return true;
20516 }
20517
20518 case MSGC_NAME:
20519 {
20520 6 doing_name_insert = true;
20521 6 sprintf(namebuf, "%s", game->get_name());
20522 6 nameptr = namebuf;
20523 6 return true;
20524 }
20525
20526 case MSGC_FONT:
20527 {
20528 int fontid = grab_next_argument();
20529 int oh = text_height(msgfont);
20530 msgfont = get_zc_font(fontid);
20531 int nh = text_height(msgfont);
20532 int mh = std::max(oh,nh);
20533 if(mh > ssc_tile_hei_buf)
20534 ssc_tile_hei_buf = mh;
20535 return true;
20536 }
20537 case MSGC_RUN_FRZ_GENSCR:
20538 {
20539 word scr_id = grab_next_argument();
20540 bool force_redraw = grab_next_argument()!=0;
20541 if(force_redraw)
20542 {
20543 update_msgstr();
20544 draw_screen(tmpscr);
20545 }
20546 FFCore.runGenericFrozenEngine(scr_id);
20547 return true;
20548 }
20549 case MSGC_DRAWTILE:
20550 {
20551 int32_t tl = grab_next_argument();
20552 int32_t cs = grab_next_argument();
20553 int32_t t_wid = grab_next_argument();
20554 int32_t t_hei = grab_next_argument();
20555 int32_t fl = grab_next_argument();
20556
20557 if(cursor_x+MsgStrings[msgstr].hspace + t_wid > msg_w-msg_margins[right])
20558 {
20559 ssc_tile_hei = ssc_tile_hei_buf;
20560 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20561 ssc_tile_hei_buf = -1;
20562 cursor_y += thei + MsgStrings[msgstr].vspace;
20563 if(bottom_margin_clip()) return true;
20564 cursor_x=msg_margins[left];
20565 }
20566
20567 overtileblock16(msg_txt_bmp_buf, tl, cursor_x, cursor_y, (int32_t)ceil(t_wid/16.0), (int32_t)ceil(t_hei/16.0), cs, fl);
20568 ssc_tile_hei_buf = zc_max(ssc_tile_hei_buf, t_hei);
20569 cursor_x += MsgStrings[msgstr].hspace + t_wid;
20570 return true;
20571 }
20572
20573 case MSGC_GOTOIFRAND:
20574 {
20575 int32_t odds = (int32_t)(grab_next_argument());
20576
20577 if(!odds || !(zc_oldrand()%odds))
20578 goto switched;
20579
20580 (void)grab_next_argument();
20581 return true;
20582 }
20583
20584 case MSGC_GOTOIFGLOBAL:
20585 {
20586 int32_t arg = (int32_t)grab_next_argument();
20587 int32_t d = zc_min(7,arg);
20588 int32_t s = ((get_currdmap())<<7) + get_currscr()-(DMaps[get_currdmap()].type==dmOVERW ? 0 : DMaps[get_currdmap()].xoff);
20589 arg = (int32_t)grab_next_argument();
20590
20591 if(game->screen_d[s][d] >= arg)
20592 goto switched;
20593
20594 (void)grab_next_argument();
20595 return true;
20596 }
20597
20598 case MSGC_CHANGEPORTRAIT:
20599 {
20600 return true; //not implemented
20601 }
20602
20603 case MSGC_GOTOIFCREEND:
20604 {
20605 int32_t dmap = (grab_next_argument()<<7); //dmap and screen may be transposed here.
20606 int32_t screen = grab_next_argument();
20607 int32_t reg = grab_next_argument();
20608 int32_t val = grab_next_argument();
20609 //int32_t nxtstr = grab_next_argument();
20610 if ( FFCore.get_screen_d(screen + dmap, reg) >= val )
20611 {
20612 goto switched;
20613 }
20614 (void)grab_next_argument();
20615 return true;
20616 }
20617
20618 case MSGC_GOTOIF:
20619 {
20620 122 int32_t it = (int32_t)grab_next_argument();
20621
20622
3/4
✓ Branch 0 taken 122 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 87 times.
✓ Branch 3 taken 35 times.
122 if(unsigned(it)<MAXITEMS && game->item[it])
20623 35 goto switched;
20624
20625 87 (void)grab_next_argument();
20626 87 return true;
20627 }
20628
20629 case MSGC_GOTOIFCTR:
20630 {
20631
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 8 times.
17 if(game->get_counter(grab_next_argument())>=grab_next_argument())
20632 9 goto switched;
20633
20634 8 (void)grab_next_argument();
20635 8 return true;
20636 }
20637
20638 case MSGC_GOTOIFCTRPC:
20639 {
20640 int32_t counter = grab_next_argument();
20641 int32_t amount = (int32_t)(((grab_next_argument())/100)*game->get_maxcounter(counter));
20642
20643 if(game->get_counter(counter)>=amount)
20644 goto switched;
20645
20646 (void)grab_next_argument();
20647 return true;
20648 }
20649
20650 case MSGC_GOTOIFTRICOUNT:
20651 {
20652 if(TriforceCount() >= (int32_t)(grab_next_argument()))
20653 goto switched;
20654
20655 (void)grab_next_argument();
20656 return true;
20657 }
20658
20659 case MSGC_GOTOIFTRI:
20660 {
20661 int32_t lev = (int32_t)(grab_next_argument());
20662
20663 if(lev<MAXLEVELS && game->lvlitems[lev]&liTRIFORCE)
20664 goto switched;
20665
20666 (void)grab_next_argument();
20667 return true;
20668 }
20669
20670 case MSGC_SETUPMENU:
20671 {
20672 2 msg_menu_data[MNU_CURSOR_TILE] = grab_next_argument();
20673 2 msg_menu_data[MNU_CURSOR_CSET] = grab_next_argument();
20674 2 msg_menu_data[MNU_CURSOR_WID] = grab_next_argument();
20675 2 msg_menu_data[MNU_CURSOR_HEI] = grab_next_argument();
20676 2 msg_menu_data[MNU_CURSOR_FLIP] = grab_next_argument();
20677 2 return true;
20678 }
20679
20680 case MSGC_MENUCHOICE:
20681 {
20682 8 int32_t pos = grab_next_argument();
20683 8 int32_t upos = grab_next_argument();
20684 8 int32_t dpos = grab_next_argument();
20685 8 int32_t lpos = grab_next_argument();
20686 8 int32_t rpos = grab_next_argument();
20687
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 2 times.
8 if(cursor_x+MsgStrings[msgstr].hspace + msg_menu_data[MNU_CURSOR_WID] > msg_w-msg_margins[right])
20688 {
20689 2 ssc_tile_hei = ssc_tile_hei_buf;
20690
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20691 2 ssc_tile_hei_buf = -1;
20692 2 cursor_y += thei + MsgStrings[msgstr].vspace;
20693
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(bottom_margin_clip()) break;
20694 2 cursor_x=msg_margins[left];
20695 2 }
20696
20697 16 menu_options[pos] = menu_choice(cursor_x, cursor_y, pos,
20698 8 upos, dpos, lpos, rpos);
20699
20700
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 4 times.
8 ssc_tile_hei_buf = zc_max(ssc_tile_hei_buf, msg_menu_data[MNU_CURSOR_HEI]);
20701 8 cursor_x += MsgStrings[msgstr].hspace + msg_menu_data[MNU_CURSOR_WID];
20702 8 return true;
20703 }
20704
20705 case MSGC_RUNMENU:
20706 {
20707 2 msg_menu_data[MNU_CHOSEN] = 0;
20708 2 msg_menu_data[MNU_CAN_CONFIRM] = 0;
20709
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(menu_options.size() < 1)
20710 return true;
20711 2 do_run_menu = true;
20712 2 return true;
20713 }
20714
20715 case MSGC_GOTOMENUCHOICE:
20716 {
20717 4 int32_t choice = grab_next_argument();
20718
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
4 if(msg_menu_data[MNU_CHOSEN] == choice)
20719 2 goto switched;
20720 2 (void)grab_next_argument();
20721 2 return true;
20722 }
20723
20724 case MSGC_ENDSTRING:
20725 {
20726 1 do_end_str = true;
20727 1 return true;
20728 }
20729 case MSGC_WAIT_ADVANCE:
20730 {
20731 wait_advance = true;
20732 linkedmsgclk = 51;
20733 return true;
20734 }
20735 case MSGC_TRIGSECRETS:
20736 {
20737 bool perm = (bool)grab_next_argument();
20738 hidden_entrance(0, true, false, -8);
20739 if(perm)
20740 setmapflag(mSECRET);
20741 return true;
20742 }
20743 case MSGC_TRIG_CMB_COPYCAT:
20744 {
20745 int copy_id = (int)grab_next_argument();
20746 if(copy_id == byte(copy_id))
20747 trig_copycat(copy_id);
20748 return true;
20749 }
20750 case MSGC_SETSCREENSTATE:
20751 {
20752 int32_t flag = int32_t(grab_next_argument());
20753 if(unsigned(flag)>=mMAXIND)
20754 {
20755 Z_error("SCC 133: Flag %d is invalid\n", flag);
20756 return true;
20757 }
20758 bool state = bool(grab_next_argument());
20759 if(state)
20760 setmapflag(1<<flag);
20761 else
20762 unsetmapflag(1<<flag,true);
20763 return true;
20764 }
20765 case MSGC_SETSCREENSTATER:
20766 {
20767 int32_t map = (int32_t)grab_next_argument();
20768 int32_t scrid = (int32_t)grab_next_argument();
20769 if(map < 1 || map > map_count)
20770 {
20771 Z_error("SCC 134: Map %d is invalid\n", map);
20772 return true;
20773 }
20774 if(unsigned(scrid)>=0x80)
20775 {
20776 Z_error("SCC 134: Screen %d is invalid\n", scrid);
20777 return true;
20778 }
20779
20780 int32_t flag = int32_t(grab_next_argument());
20781 if(unsigned(flag)>=mMAXIND)
20782 {
20783 Z_error("SCC 134: Flag %d is invalid\n", flag);
20784 return true;
20785 }
20786 bool state = bool(grab_next_argument());
20787 if(state)
20788 setmapflag(mapind(map,scrid),1<<flag);
20789 else
20790 unsetmapflag(mapind(map,scrid),1<<flag,true);
20791 return true;
20792 }
20793 switched:
20794 46 int32_t lev = (int32_t)(grab_next_argument());
20795
2/4
✓ Branch 0 taken 46 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
46 if(lev && get_qr(qr_SCC_GOTO_RESPECTS_CONTFLAG)
20796
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 33 times.
46 && (MsgStrings[lev].stringflags & STRINGFLAG_CONT))
20797 {
20798 msgstr=lev;
20799 msgpos=msgptr=0;
20800 msgfont=setmsgfont();
20801 }
20802 else
20803 {
20804 46 donewmsg(lev);
20805 46 ssc_tile_hei_buf = -1;
20806 }
20807 46 msgptr--; // To counteract it being incremented after this routine is called.
20808 46 putprices(false);
20809 46 return true;
20810 }
20811
20812 238927 return false;
20813 244846 }
20814
20815 // Wraps the message string... probably.
20816 235409 void wrapmsgstr(char *s3)
20817 {
20818 235409 int32_t j=0;
20819
20820
2/2
✓ Branch 0 taken 23941 times.
✓ Branch 1 taken 211468 times.
235409 if(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP)
20821 {
20822
2/2
✓ Branch 0 taken 4767 times.
✓ Branch 1 taken 19174 times.
23941 if(msgspace)
20823 {
20824 4767 char c = MsgStrings[msgstr].s[msgptr];
20825
4/6
✓ Branch 0 taken 4440 times.
✓ Branch 1 taken 327 times.
✓ Branch 2 taken 4440 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4440 times.
✗ Branch 5 not taken.
4767 if(c != ' ' && c >= 32 && c <= 126)
20826 {
20827
4/4
✓ Branch 0 taken 122 times.
✓ Branch 1 taken 24450 times.
✓ Branch 2 taken 20132 times.
✓ Branch 3 taken 4440 times.
24572 for(int32_t k=0; MsgStrings[msgstr].s[msgptr+k] && MsgStrings[msgstr].s[msgptr+k] != ' '; k++)
20828 {
20829
3/4
✓ Branch 0 taken 19569 times.
✓ Branch 1 taken 563 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 19569 times.
20132 if(MsgStrings[msgstr].s[msgptr+k] >= 32 && MsgStrings[msgstr].s[msgptr+k] <= 126) s3[j++] = MsgStrings[msgstr].s[msgptr+k];
20830 20132 }
20831
20832 4440 s3[j] = 0;
20833 4440 msgspace = false;
20834 4440 }
20835 else
20836 {
20837 327 s3[0] = c;
20838 327 s3[1] = 0;
20839 }
20840 4767 }
20841 else
20842 {
20843 19174 s3[0] = MsgStrings[msgstr].s[msgptr];
20844 19174 s3[1] = 0;
20845
20846
2/2
✓ Branch 0 taken 15129 times.
✓ Branch 1 taken 4045 times.
19174 if(s3[0] == ' ') msgspace=true;
20847 }
20848 23941 }
20849 else
20850 {
20851 211468 s3[0] = MsgStrings[msgstr].s[msgptr];
20852 211468 s3[1] = 0;
20853 }
20854 235409 }
20855
20856 // Returns true if the pointer is at a string's
20857 // null terminator or a trailing space
20858 812381 bool atend(char const* str)
20859 {
20860 812381 int32_t i=0;
20861
20862
2/2
✓ Branch 0 taken 6386196 times.
✓ Branch 1 taken 812381 times.
7198577 while(str[i]==' ')
20863 6386196 i++;
20864
20865 812381 return str[i]=='\0';
20866 }
20867
20868 14463512 void putmsg()
20869 {
20870 14463512 bool oldmargin = get_qr(qr_OLD_STRING_EDITOR_MARGINS)!=0;
20871
2/2
✓ Branch 0 taken 676673 times.
✓ Branch 1 taken 13786839 times.
14463512 if(!msgorig) msgorig=msgstr;
20872
20873
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14463512 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14463512 if(wait_advance && linkedmsgclk < 1)
20874 linkedmsgclk = 1;
20875
2/2
✓ Branch 0 taken 14189026 times.
✓ Branch 1 taken 274486 times.
14463512 if(linkedmsgclk>0)
20876 {
20877
2/2
✓ Branch 0 taken 126285 times.
✓ Branch 1 taken 148201 times.
274486 if(linkedmsgclk==1)
20878 {
20879
6/6
✓ Branch 0 taken 126284 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 123429 times.
✓ Branch 3 taken 2855 times.
✓ Branch 4 taken 108 times.
✓ Branch 5 taken 123321 times.
126285 if(do_end_str||cAbtn()||cBbtn())
20880 {
20881 2964 do_end_str = false;
20882 2964 linkedmsgclk = 0;
20883
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2964 times.
2964 if(wait_advance)
20884 {
20885 wait_advance = false;
20886 }
20887 else
20888 {
20889 2964 msgstr=MsgStrings[msgstr].nextstring;
20890 2964 ssc_tile_hei_buf = -1;
20891
3/4
✓ Branch 0 taken 962 times.
✓ Branch 1 taken 2002 times.
✓ Branch 2 taken 962 times.
✗ Branch 3 not taken.
2964 if(!msgstr && enqueued_str)
20892 {
20893 msgstr = enqueued_str;
20894 enqueued_str = 0;
20895 }
20896
2/2
✓ Branch 0 taken 2002 times.
✓ Branch 1 taken 962 times.
2964 if(!msgstr)
20897 {
20898 962 msgfont=get_zc_font(font_zfont);
20899
20900
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 958 times.
962 if(tmpscr->room!=rGRUMBLE)
20901 958 blockpath=false;
20902
20903 962 dismissmsg();
20904 962 goto disappear;
20905 }
20906
20907 2002 donewmsg(msgstr);
20908 2002 putprices(false);
20909 }
20910 2002 }
20911 125323 }
20912 else
20913 {
20914 148201 --linkedmsgclk;
20915 }
20916 273524 }
20917
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14462550 times.
14462550 if(wait_advance) return; //Waiting for buttonpress
20918
20919
10/10
✓ Branch 0 taken 14460237 times.
✓ Branch 1 taken 2313 times.
✓ Branch 2 taken 671478 times.
✓ Branch 3 taken 13788759 times.
✓ Branch 4 taken 534825 times.
✓ Branch 5 taken 136653 times.
✓ Branch 6 taken 269613 times.
✓ Branch 7 taken 265212 times.
✓ Branch 8 taken 854 times.
✓ Branch 9 taken 268759 times.
14462550 if(!do_run_menu && (!msgstr || msgpos>=10000 || msgptr>=MsgStrings[msgstr].s.size() || bottom_margin_clip()))
20920 {
20921
2/2
✓ Branch 0 taken 402719 times.
✓ Branch 1 taken 13788759 times.
14191478 if(!msgstr)
20922 13788759 msgorig=0;
20923
20924 14191478 msg_active = false;
20925 14191478 return;
20926 }
20927
20928 271072 msg_onscreen = true; // Now the message is onscreen (see donewmsg()).
20929
20930 char s3[145];
20931 int32_t tlength;
20932
20933 // Bypass the string with the B button!
20934
4/4
✓ Branch 0 taken 1343 times.
✓ Branch 1 taken 269729 times.
✓ Branch 2 taken 1242 times.
✓ Branch 3 taken 268487 times.
271072 if(((cBbtn())&&(get_qr(qr_ALLOWMSGBYPASS))) || msgspeed==0)
20935 {
20936 //finish writing out the string
20937
4/4
✓ Branch 0 taken 103 times.
✓ Branch 1 taken 79079 times.
✓ Branch 2 taken 1232 times.
✓ Branch 3 taken 77950 times.
80532 while(msgptr<MsgStrings[msgstr].s.size() && !atend(MsgStrings[msgstr].s.c_str()+msgptr))
20938 {
20939
5/6
✓ Branch 0 taken 18710 times.
✓ Branch 1 taken 59240 times.
✓ Branch 2 taken 18707 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 18707 times.
✗ Branch 5 not taken.
77950 if(msgspeed && !(cBbtn() && get_qr(qr_ALLOWMSGBYPASS)))
20940 3 goto breakout; // break out if message speed was changed to non-zero
20941
4/6
✓ Branch 0 taken 77947 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 77947 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 287 times.
✓ Branch 5 taken 77660 times.
77947 else if(!do_run_menu && !doing_name_insert && !parsemsgcode())
20942 {
20943
1/2
✓ Branch 0 taken 77660 times.
✗ Branch 1 not taken.
77660 if(bottom_margin_clip())
20944 break;
20945
20946 77660 wrapmsgstr(s3);
20947
20948
2/2
✓ Branch 0 taken 20449 times.
✓ Branch 1 taken 57211 times.
77660 if(MsgStrings[msgstr].s[msgptr]==' ')
20949 {
20950 20449 tlength = msgfont->vtable->char_length(msgfont, MsgStrings[msgstr].s[msgptr]) + MsgStrings[msgstr].hspace;
20951
20952
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 1347 times.
21843 if(cursor_x+tlength > (msg_w-msg_margins[right])
20953
5/6
✓ Branch 0 taken 1394 times.
✓ Branch 1 taken 19055 times.
✓ Branch 2 taken 1394 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1300 times.
✓ Branch 5 taken 47 times.
20449 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
20954 47 ? true : strcmp(s3," ")!=0))
20955 {
20956 1347 ssc_tile_hei = ssc_tile_hei_buf;
20957
1/2
✓ Branch 0 taken 1347 times.
✗ Branch 1 not taken.
1347 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20958 1347 ssc_tile_hei_buf = -1;
20959 1347 cursor_y += thei + MsgStrings[msgstr].vspace;
20960
1/2
✓ Branch 0 taken 1347 times.
✗ Branch 1 not taken.
1347 if(bottom_margin_clip()) break;
20961 1347 cursor_x=msg_margins[left];
20962 1347 }
20963
20964 20449 char buf[2] = {0};
20965 20449 sprintf(buf,"%c",MsgStrings[msgstr].s[msgptr]);
20966
20967 20449 textout_styled_aligned_ex(msg_txt_bmp_buf,msgfont,buf,cursor_x,cursor_y,msg_shdtype,sstaLEFT,msgcolour,msg_shdcol,-1);
20968
20969 20449 cursor_x+=tlength;
20970 20449 }
20971 else
20972 {
20973 57211 tlength = text_length(msgfont, s3) + ((int32_t)strlen(s3)*MsgStrings[msgstr].hspace);
20974
2/2
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 536 times.
57937 if(cursor_x+tlength > (msg_w-msg_margins[right])
20975
5/6
✓ Branch 0 taken 773 times.
✓ Branch 1 taken 56438 times.
✓ Branch 2 taken 726 times.
✓ Branch 3 taken 47 times.
✓ Branch 4 taken 583 times.
✗ Branch 5 not taken.
57211 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
20976 190 ? true : strcmp(s3," ")!=0))
20977 {
20978 773 ssc_tile_hei = ssc_tile_hei_buf;
20979
1/2
✓ Branch 0 taken 773 times.
✗ Branch 1 not taken.
773 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20980 773 ssc_tile_hei_buf = -1;
20981 773 cursor_y += thei + MsgStrings[msgstr].vspace;
20982
1/2
✓ Branch 0 taken 773 times.
✗ Branch 1 not taken.
773 if(bottom_margin_clip()) break;
20983 773 cursor_x=msg_margins[left];
20984 773 }
20985
20986 57211 sfx(MsgStrings[msgstr].sfx);
20987
20988 57211 char buf[2] = {0};
20989 57211 sprintf(buf,"%c",MsgStrings[msgstr].s[msgptr]);
20990
20991 57211 textout_styled_aligned_ex(msg_txt_bmp_buf,msgfont,buf,cursor_x,cursor_y,msg_shdtype,sstaLEFT,msgcolour,msg_shdcol,-1);
20992
20993 57211 cursor_x += msgfont->vtable->char_length(msgfont, MsgStrings[msgstr].s[msgptr]);
20994 57211 cursor_x += MsgStrings[msgstr].hspace;
20995 }
20996
20997 77660 msgpos++;
20998 77660 }
20999
1/2
✓ Branch 0 taken 77947 times.
✗ Branch 1 not taken.
77947 if(do_run_menu)
21000 {
21001 if(runMenuCursor())
21002 {
21003 do_run_menu = false;
21004 }
21005 else break;
21006 }
21007
1/2
✓ Branch 0 taken 77947 times.
✗ Branch 1 not taken.
77947 if(doing_name_insert)
21008 {
21009 if(*nameptr)
21010 {
21011 if(bottom_margin_clip())
21012 break;
21013
21014 char s3[9] = {0};
21015
21016 if(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP)
21017 {
21018 strcpy(s3, nameptr);
21019 }
21020 else
21021 {
21022 s3[0] = *nameptr;
21023 s3[1] = 0;
21024 }
21025
21026 tlength = text_length(msgfont, s3) + ((int32_t)strlen(s3)*MsgStrings[msgstr].hspace);
21027
21028 if(cursor_x+tlength > (msg_w-msg_margins[right])
21029 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
21030 ? true : strcmp(s3," ")!=0))
21031 {
21032 ssc_tile_hei = ssc_tile_hei_buf;
21033 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
21034 ssc_tile_hei_buf = -1;
21035 cursor_y += thei + MsgStrings[msgstr].vspace;
21036 if(bottom_margin_clip()) break;
21037 cursor_x=msg_margins[left];
21038 }
21039
21040 sfx(MsgStrings[msgstr].sfx);
21041
21042 char buf[2] = {0};
21043 sprintf(buf,"%c",*nameptr);
21044
21045 textout_styled_aligned_ex(msg_txt_bmp_buf,msgfont,buf,cursor_x,cursor_y,msg_shdtype,sstaLEFT,msgcolour,msg_shdcol,-1);
21046
21047 cursor_x += msgfont->vtable->char_length(msgfont, *nameptr);
21048 cursor_x += MsgStrings[msgstr].hspace;
21049 ++nameptr;
21050 continue; //don't advance the msgptr, as the next char in it was not processed!
21051 }
21052 else doing_name_insert = false;
21053 }
21054 77947 ++msgptr;
21055
1/2
✓ Branch 0 taken 77947 times.
✗ Branch 1 not taken.
77947 if(do_end_str)
21056 goto strendcheck;
21057
1/2
✓ Branch 0 taken 77947 times.
✗ Branch 1 not taken.
77947 if(wait_advance)
21058 return;
21059
2/2
✓ Branch 0 taken 76734 times.
✓ Branch 1 taken 1213 times.
77947 if(atend(MsgStrings[msgstr].s.c_str()+msgptr))
21060 {
21061
2/2
✓ Branch 0 taken 427 times.
✓ Branch 1 taken 786 times.
1213 if(MsgStrings[msgstr].nextstring)
21062 {
21063
1/2
✓ Branch 0 taken 786 times.
✗ Branch 1 not taken.
786 if(MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT)
21064 {
21065 msgstr=MsgStrings[msgstr].nextstring;
21066 msgpos=msgptr=0;
21067 msgfont=setmsgfont();
21068 }
21069 786 }
21070 1213 }
21071 }
21072
21073
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1232 times.
1232 if (!do_run_menu)
21074 {
21075 1232 msgclk = 72;
21076 1232 msgpos = 10000;
21077 1232 }
21078 1232 }
21079 else
21080 268487 {
21081 breakout:
21082 268490 word tempspeed = msgspeed;
21083
2/2
✓ Branch 0 taken 267527 times.
✓ Branch 1 taken 963 times.
268490 if (do_run_menu)
21084 963 tempspeed = 0;
21085
6/6
✓ Branch 0 taken 215742 times.
✓ Branch 1 taken 52748 times.
✓ Branch 2 taken 125018 times.
✓ Branch 3 taken 90724 times.
✓ Branch 4 taken 114243 times.
✓ Branch 5 taken 10775 times.
268490 if(((msgclk++)%(tempspeed+1)<tempspeed)&&((!cAbtn())||(!get_qr(qr_ALLOWFASTMSG))))
21086 101499 return;
21087 }
21088
21089 // Start writing the string
21090
2/2
✓ Branch 0 taken 165303 times.
✓ Branch 1 taken 2920 times.
171143 if(msgptr == 0)
21091 {
21092
2/2
✓ Branch 0 taken 2920 times.
✓ Branch 1 taken 5068 times.
7988 while(MsgStrings[msgstr].s[msgptr]==' ')
21093 {
21094 5068 tlength = msgfont->vtable->char_length(msgfont, MsgStrings[msgstr].s[msgptr]) + MsgStrings[msgstr].hspace;
21095
21096
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
5156 if(cursor_x+tlength > (msg_w-msg_margins[right])
21097
4/6
✓ Branch 0 taken 4980 times.
✓ Branch 1 taken 88 times.
✓ Branch 2 taken 88 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 88 times.
✗ Branch 5 not taken.
5068 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
21098 ? 1 : strcmp(s3," ")!=0))
21099 {
21100 88 ssc_tile_hei = ssc_tile_hei_buf;
21101
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
21102 88 ssc_tile_hei_buf = -1;
21103 88 cursor_y += thei + MsgStrings[msgstr].vspace;
21104
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(bottom_margin_clip()) break;
21105 88 cursor_x=msg_margins[left];
21106 88 }
21107
21108 5068 cursor_x+=tlength;
21109 5068 ++msgptr;
21110 5068 ++msgpos;
21111
21112 // The "Continue From Previous" feature
21113
2/2
✓ Branch 0 taken 3700 times.
✓ Branch 1 taken 1368 times.
5068 if(atend(MsgStrings[msgstr].s.c_str()+msgptr))
21114 {
21115
1/2
✓ Branch 0 taken 1368 times.
✗ Branch 1 not taken.
1368 if(MsgStrings[msgstr].nextstring)
21116 {
21117 if(MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT)
21118 {
21119 msgstr=MsgStrings[msgstr].nextstring;
21120 msgpos=msgptr=0;
21121 msgfont=setmsgfont();
21122 }
21123 }
21124 1368 }
21125 }
21126 2920 }
21127
21128 reparsesinglechar:
21129 // Continue printing the string!
21130
3/4
✓ Branch 0 taken 161646 times.
✓ Branch 1 taken 6579 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 161646 times.
329868 if(!atend(MsgStrings[msgstr].s.c_str()+msgptr) && !bottom_margin_clip())
21131 {
21132
6/6
✓ Branch 0 taken 160683 times.
✓ Branch 1 taken 963 times.
✓ Branch 2 taken 160659 times.
✓ Branch 3 taken 24 times.
✓ Branch 4 taken 2910 times.
✓ Branch 5 taken 157749 times.
161646 if(!do_run_menu && !doing_name_insert && !parsemsgcode())
21133 {
21134 157749 wrapmsgstr(s3);
21135
21136 157749 tlength = text_length(msgfont, s3) + ((int32_t)strlen(s3)*MsgStrings[msgstr].hspace);
21137
21138
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 1915 times.
159920 if(cursor_x+tlength > (msg_w-msg_margins[right])
21139
6/6
✓ Branch 0 taken 2214 times.
✓ Branch 1 taken 155535 times.
✓ Branch 2 taken 2171 times.
✓ Branch 3 taken 43 times.
✓ Branch 4 taken 1915 times.
✓ Branch 5 taken 43 times.
157749 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
21140 256 ? true : strcmp(s3," ")!=0))
21141 {
21142 2171 ssc_tile_hei = ssc_tile_hei_buf;
21143
1/2
✓ Branch 0 taken 2171 times.
✗ Branch 1 not taken.
2171 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
21144 2171 ssc_tile_hei_buf = -1;
21145 2171 cursor_y += thei + MsgStrings[msgstr].vspace;
21146
1/2
✓ Branch 0 taken 2171 times.
✗ Branch 1 not taken.
2171 if(bottom_margin_clip()) goto strendcheck;
21147 2171 cursor_x=msg_margins[left];
21148 //if(space) s3[0]=0;
21149 2171 }
21150
21151 157749 sfx(MsgStrings[msgstr].sfx);
21152
21153 157749 char buf[2] = {0};
21154 157749 sprintf(buf,"%c",MsgStrings[msgstr].s[msgptr]);
21155
21156 157749 textout_styled_aligned_ex(msg_txt_bmp_buf,msgfont,buf,cursor_x,cursor_y,msg_shdtype,sstaLEFT,msgcolour,msg_shdcol,-1);
21157
21158 157749 cursor_x += msgfont->vtable->char_length(msgfont, MsgStrings[msgstr].s[msgptr]);
21159 157749 cursor_x += MsgStrings[msgstr].hspace;
21160 157749 msgpos++;
21161 157749 }
21162
2/2
✓ Branch 0 taken 161645 times.
✓ Branch 1 taken 1 times.
161646 if(do_end_str)
21163 1 goto strendcheck;
21164
1/2
✓ Branch 0 taken 161645 times.
✗ Branch 1 not taken.
161645 if(wait_advance)
21165 {
21166 ++msgptr;
21167 return;
21168 }
21169
2/2
✓ Branch 0 taken 965 times.
✓ Branch 1 taken 160680 times.
161645 else if(do_run_menu)
21170 {
21171
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 963 times.
965 if(runMenuCursor())
21172 {
21173 2 do_run_menu = false;
21174 2 ++msgptr;
21175 2 goto reparsesinglechar;
21176 }
21177 963 }
21178
4/4
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 160650 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 24 times.
160680 else if(doing_name_insert && *nameptr)
21179 {
21180 24 char s3[9] = {0};
21181
21182
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP)
21183 {
21184 24 strcpy(s3, nameptr);
21185 24 }
21186 else
21187 {
21188 s3[0] = *nameptr;
21189 s3[1] = 0;
21190 }
21191
21192 24 tlength = text_length(msgfont, s3) + ((int32_t)strlen(s3)*MsgStrings[msgstr].hspace);
21193
21194
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
24 if(cursor_x+tlength > (msg_w-msg_margins[right])
21195
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
24 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
21196 ? true : strcmp(s3," ")!=0))
21197 {
21198 ssc_tile_hei = ssc_tile_hei_buf;
21199 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
21200 ssc_tile_hei_buf = -1;
21201 cursor_y += thei + MsgStrings[msgstr].vspace;
21202 if(bottom_margin_clip()) goto strendcheck;
21203 cursor_x=msg_margins[left];
21204 }
21205
21206 24 sfx(MsgStrings[msgstr].sfx);
21207
21208 24 char buf[2] = {0};
21209 24 sprintf(buf,"%c",*nameptr);
21210
21211 24 textout_styled_aligned_ex(msg_txt_bmp_buf,msgfont,buf,cursor_x,cursor_y,msg_shdtype,sstaLEFT,msgcolour,msg_shdcol,-1);
21212
21213 24 cursor_x += msgfont->vtable->char_length(msgfont, *nameptr);
21214 24 cursor_x += MsgStrings[msgstr].hspace;
21215 24 ++nameptr;
21216 24 }
21217 else
21218 {
21219 160656 doing_name_insert = false;
21220 160656 msgptr++;
21221
21222
2/2
✓ Branch 0 taken 157928 times.
✓ Branch 1 taken 2728 times.
160656 if(atend(MsgStrings[msgstr].s.c_str()+msgptr))
21223 {
21224
2/2
✓ Branch 0 taken 1511 times.
✓ Branch 1 taken 1217 times.
2728 if(MsgStrings[msgstr].nextstring)
21225 {
21226
1/2
✓ Branch 0 taken 1217 times.
✗ Branch 1 not taken.
1217 if(MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT)
21227 {
21228 msgstr=MsgStrings[msgstr].nextstring;
21229 msgpos=msgptr=0;
21230 msgfont=setmsgfont();
21231 }
21232 1217 }
21233 2728 }
21234
21235
2/2
✓ Branch 0 taken 23887 times.
✓ Branch 1 taken 4560 times.
189103 if(MsgStrings[msgstr].s.size() > unsigned(msgptr+1)
21236
2/2
✓ Branch 0 taken 160101 times.
✓ Branch 1 taken 555 times.
160656 && (MsgStrings[msgstr].s[msgptr]==' ')
21237
2/2
✓ Branch 0 taken 28447 times.
✓ Branch 1 taken 131654 times.
160101 && (MsgStrings[msgstr].s[msgptr+1]==' '))
21238 {
21239
2/2
✓ Branch 0 taken 4554 times.
✓ Branch 1 taken 158015 times.
162569 while(MsgStrings[msgstr].s[msgptr]==' ')
21240 {
21241 158015 msgspace = true;
21242 158015 tlength = msgfont->vtable->char_length(msgfont, MsgStrings[msgstr].s[msgptr]) + MsgStrings[msgstr].hspace;
21243
21244
2/2
✓ Branch 0 taken 464 times.
✓ Branch 1 taken 6331 times.
164810 if(cursor_x+tlength > (msg_w-msg_margins[right])
21245
4/6
✓ Branch 0 taken 6795 times.
✓ Branch 1 taken 151220 times.
✓ Branch 2 taken 6795 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6331 times.
✗ Branch 5 not taken.
158015 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
21246 464 ? true : strcmp(s3," ")!=0))
21247 {
21248 6795 ssc_tile_hei = ssc_tile_hei_buf;
21249
1/2
✓ Branch 0 taken 6795 times.
✗ Branch 1 not taken.
6795 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
21250 6795 ssc_tile_hei_buf = -1;
21251 6795 cursor_y += thei + MsgStrings[msgstr].vspace;
21252
2/2
✓ Branch 0 taken 6789 times.
✓ Branch 1 taken 6 times.
6795 if(bottom_margin_clip()) break;
21253 6789 cursor_x=msg_margins[left];
21254 6789 }
21255
21256 158009 cursor_x+=tlength;
21257 158009 ++msgpos;
21258 158009 ++msgptr;
21259
21260
2/2
✓ Branch 0 taken 10281 times.
✓ Branch 1 taken 147728 times.
158009 if(atend(MsgStrings[msgstr].s.c_str()+msgptr))
21261 {
21262
2/2
✓ Branch 0 taken 87663 times.
✓ Branch 1 taken 60065 times.
147728 if(MsgStrings[msgstr].nextstring)
21263 {
21264
1/2
✓ Branch 0 taken 60065 times.
✗ Branch 1 not taken.
60065 if(MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT)
21265 {
21266 msgstr=MsgStrings[msgstr].nextstring;
21267 msgpos=msgptr=0;
21268 msgfont=setmsgfont();
21269 }
21270 60065 }
21271 147728 }
21272 }
21273 4560 }
21274 }
21275 161643 }
21276 strendcheck:
21277 // Done printing the string
21278
14/14
✓ Branch 0 taken 168222 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 168198 times.
✓ Branch 3 taken 24 times.
✓ Branch 4 taken 167235 times.
✓ Branch 5 taken 963 times.
✓ Branch 6 taken 166003 times.
✓ Branch 7 taken 1232 times.
✓ Branch 8 taken 163403 times.
✓ Branch 9 taken 2600 times.
✓ Branch 10 taken 163397 times.
✓ Branch 11 taken 6 times.
✓ Branch 12 taken 160995 times.
✓ Branch 13 taken 6240 times.
168223 if(do_end_str || !doing_name_insert && !do_run_menu && (msgpos>=10000 || msgptr>=MsgStrings[msgstr].s.size() || bottom_margin_clip() || atend(MsgStrings[msgstr].s.c_str()+msgptr)) && !linkedmsgclk)
21279 {
21280
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 6240 times.
6241 if(!do_end_str)
21281
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6240 times.
6240 while(parsemsgcode()); // Finish remaining control codes
21282
21283 // Go to next string, or make it disappear by going to string 0.
21284
5/6
✓ Branch 0 taken 4238 times.
✓ Branch 1 taken 2003 times.
✓ Branch 2 taken 3275 times.
✓ Branch 3 taken 963 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3275 times.
6241 if(MsgStrings[msgstr].nextstring!=0 || get_qr(qr_MSGDISAPPEAR) || enqueued_str)
21285 {
21286 2966 linkedmsgclk=do_end_str?1:51;
21287 2966 }
21288
21289
2/2
✓ Branch 0 taken 4238 times.
✓ Branch 1 taken 2003 times.
6241 if(MsgStrings[msgstr].nextstring==0)
21290 {
21291
2/2
✓ Branch 0 taken 963 times.
✓ Branch 1 taken 3275 times.
4238 if(!get_qr(qr_MSGDISAPPEAR))
21292 3275 {
21293 disappear:
21294 4237 msg_active = false;
21295 4237 Hero.finishedmsg();
21296 4237 }
21297
21298
2/2
✓ Branch 0 taken 5187 times.
✓ Branch 1 taken 13 times.
5200 if(repaircharge)
21299 {
21300 13 game->change_drupy(-tmpscr[currscr<128?0:1].catchall);
21301 13 repaircharge = 0;
21302 13 }
21303
21304
2/2
✓ Branch 0 taken 5198 times.
✓ Branch 1 taken 2 times.
5200 if(adjustmagic)
21305 {
21306
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(get_qr(qr_OLD_HALF_MAGIC))
21307 {
21308
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(game->get_magicdrainrate())
21309 2 game->set_magicdrainrate(1);
21310 2 }
21311 else if(game->get_magicdrainrate() > 1)
21312 {
21313 game->set_magicdrainrate(game->get_magicdrainrate()/2);
21314 }
21315 2 adjustmagic = false;
21316 2 sfx(WAV_SCALE);
21317
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
2 setmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
21318 2 }
21319
21320
2/2
✓ Branch 0 taken 5198 times.
✓ Branch 1 taken 2 times.
5200 if(learnslash)
21321 {
21322 2 game->set_canslash(1);
21323 2 learnslash = false;
21324 2 sfx(WAV_SCALE);
21325
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 setmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
21326 2 }
21327 5200 }
21328 7203 }
21329 14462162 }
21330
21331 124290 int32_t message_more_y()
21332 {
21333 //Is the flag ticked, do we really want a message more y larger than 160?
21334
5/6
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 124262 times.
✓ Branch 2 taken 124290 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 124262 times.
✓ Branch 5 taken 28 times.
124290 int32_t msgy=zc_min((zinit.msg_more_is_offset==0)?zinit.msg_more_y:zinit.msg_more_y+MsgStrings[msgstr].y ,160);
21335 124290 msgy+=playing_field_offset;
21336 124290 return msgy;
21337 }
21338
21339 /*** Collision detection & handling ***/
21340
21341 14156012 void clear_script_one_frame_conditions()
21342 {
21343
2/2
✓ Branch 0 taken 38767433 times.
✓ Branch 1 taken 14156012 times.
52923445 for(int32_t j=0; j<guys.Count(); j++)
21344 {
21345 38767433 enemy *e = (enemy*)guys.spr(j);
21346
2/2
✓ Branch 0 taken 659046361 times.
✓ Branch 1 taken 38767433 times.
697813794 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) e->hitby[q] = 0;
21347 38767433 }
21348 14156012 }
21349
21350 4854872 void check_enemy_lweapon_collision(weapon *w)
21351 {
21352
8/8
✓ Branch 0 taken 4242795 times.
✓ Branch 1 taken 612077 times.
✓ Branch 2 taken 3253573 times.
✓ Branch 3 taken 989222 times.
✓ Branch 4 taken 3191489 times.
✓ Branch 5 taken 62084 times.
✓ Branch 6 taken 16738 times.
✓ Branch 7 taken 3174751 times.
4854872 if(!(w->Dead()) && w->id!=wSword && w->id!=wHammer && w->id!=wWand)
21353 {
21354
2/2
✓ Branch 0 taken 3159180 times.
✓ Branch 1 taken 11159478 times.
14318658 for(int32_t j=0; j<guys.Count(); j++)
21355 {
21356 11159478 enemy *e = (enemy*)guys.spr(j);
21357
21358 11159478 bool didhit = e->hit(w);
21359
2/2
✓ Branch 0 taken 10939046 times.
✓ Branch 1 taken 220432 times.
11159478 if(didhit) //boomerangs and such that last for more than a frame can write hitby[] for more than one frame,
21360 //because this only checks `if(dying || clk<0 || hclk>0 || superman)`
21361 {
21362 // !(e->stunclk)
21363 220432 int32_t h = e->takehit(w);
21364
2/2
✓ Branch 0 taken 187002 times.
✓ Branch 1 taken 33430 times.
220432 if (h == -1)
21365 {
21366 33430 int indx = Lwpns.find(w);
21367
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33430 times.
33430 if(indx > -1)
21368 33430 e->hitby[HIT_BY_LWEAPON] = indx+1;
21369 33430 e->hitby[HIT_BY_LWEAPON_UID] = w->script_UID;
21370 33430 e->hitby[HIT_BY_LWEAPON_TYPE] = w->id;
21371
2/2
✓ Branch 0 taken 31260 times.
✓ Branch 1 taken 2170 times.
33430 if (w->parentitem > -1) e->hitby[HIT_BY_LWEAPON_PARENT_FAMILY] = itemsbuf[w->parentitem].family;
21372 2170 else e->hitby[HIT_BY_LWEAPON_PARENT_FAMILY] = -1;
21373 33430 e->hitby[HIT_BY_LWEAPON_PARENT_ID] = w->parentitem;
21374 33430 e->hitby[HIT_BY_LWEAPON_ENGINE_UID] = w->getUID();
21375
21376 33430 }
21377 //we may need to handle this in special cases. -Z
21378
21379 //if h == stun or ignore
21380
21381 //if e->stun > DEFAULT_STUN -1 || !e->stun
21382 //if the enemy wasn't stunned this round -- what a bitch, as the stun value is set before we check this
21383 ///! how about: if w->dead != bounce !
21384
21385 // NOT FOR PUBLIC RELEASE
21386 /*if(h==3) //Mirror shield
21387 {
21388 if (w->id==ewFireball || w->id==wRefFireball)
21389 {
21390 w->id=wRefFireball;
21391 switch(e->dir)
21392 {
21393 case up: e->angle += (PI - e->angle) * 2.0; break;
21394 case down: e->angle = -e->angle; break;
21395 case left: e->angle += ((-PI/2) - e->angle) * 2.0; break;
21396 case right: e->angle += (( PI/2) - e->angle) * 2.0; break;
21397 // TODO: the following. -L.
21398 case l_up: break;
21399 case r_up: break;
21400 case l_down: break;
21401 case r_down: break;
21402 }
21403 }
21404 else
21405 {
21406 w->id = ((w->id==ewMagic || w->id==wRefMagic || w->id==wMagic) ? wRefMagic : wRefBeam);
21407 w->dir ^= 1;
21408 if(w->dir&2)
21409 w->flip ^= 1;
21410 else
21411 w->flip ^= 2;
21412 }
21413 w->ignoreHero=false;
21414 }
21415 else*/
21416
2/2
✓ Branch 0 taken 176399 times.
✓ Branch 1 taken 44033 times.
220432 if(h)
21417 {
21418
3/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 44029 times.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
44033 if(e->switch_hooked && w->family_class == itype_switchhook)
21419 w->onhit(false, e, -1);
21420 44033 else w->onhit(false, e, h);
21421 44033 }
21422
21423
2/2
✓ Branch 0 taken 217758 times.
✓ Branch 1 taken 2674 times.
220432 if(h==2)
21424 {
21425 2674 break;
21426 }
21427 217758 }
21428
21429
2/2
✓ Branch 0 taken 11143907 times.
✓ Branch 1 taken 12897 times.
11156804 if(w->Dead())
21430 {
21431 12897 break;
21432 }
21433 11143907 }
21434
21435 // Item flags added in 2.55:
21436 // BRang/HShot/Arrows item_flag4 is "Pick up anything" (port of qr_BRANGPICKUP)
21437 // BRang/HShot item_flag5 is "Drags Items" (port of qr_Z3BRANG_HSHOT)
21438 // Arrows item_flag2 is "Picks up items" (inverse port of qr_Z3BRANG_HSHOT)
21439 // -Em
21440
6/6
✓ Branch 0 taken 2720768 times.
✓ Branch 1 taken 453983 times.
✓ Branch 2 taken 2676196 times.
✓ Branch 3 taken 44572 times.
✓ Branch 4 taken 43559 times.
✓ Branch 5 taken 2632637 times.
3174751 if(w->id == wBrang || w->id == wHookshot || w->id == wArrow)
21441 {
21442 542114 int32_t itype, pitem = w->parentitem;
21443
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 453983 times.
✓ Branch 2 taken 43559 times.
✓ Branch 3 taken 44572 times.
542114 switch(w->id)
21444 {
21445 453983 case wBrang: itype = itype_brang; break;
21446 43559 case wArrow: itype = itype_arrow; break;
21447 case wHookshot:
21448 44572 itype = (w->family_class == itype_switchhook ? itype_switchhook :itype_hookshot);
21449 44572 break;
21450 }
21451
2/2
✓ Branch 0 taken 537262 times.
✓ Branch 1 taken 4852 times.
542114 if(pitem < 0) pitem = current_item_id(itype);
21452
5/6
✓ Branch 0 taken 44572 times.
✓ Branch 1 taken 497542 times.
✓ Branch 2 taken 100 times.
✓ Branch 3 taken 44472 times.
✓ Branch 4 taken 100 times.
✗ Branch 5 not taken.
542114 if(w->id == wHookshot && w->family_class == itype_switchhook && (itemsbuf[pitem].flags & item_flag9))
21453 { //Swap with item
21454 for(int32_t j=0; j<items.Count(); j++)
21455 {
21456 if(items.spr(j)->hit(w))
21457 {
21458 item *theItem = ((item*)items.spr(j));
21459 bool priced = theItem->PriceIndex >-1;
21460 bool isKey = itemsbuf[theItem->id].family==itype_key||itemsbuf[theItem->id].family==itype_lkey;
21461 if(!theItem->fallclk && !theItem->drownclk && ((theItem->pickup & ipTIMER && theItem->clk2 >= 32)
21462 || (((itemsbuf[w->parentitem].flags & item_flag4)||(theItem->pickup & ipCANGRAB)||((itemsbuf[w->parentitem].flags & item_flag7)&&isKey)) && !priced && !(theItem->pickup & ipDUMMY))))
21463 {
21464 if(!Hero.switchhookclk)
21465 {
21466 hooked_combopos = -1;
21467 hooked_layerbits = 0;
21468 switching_object = theItem;
21469 theItem->switch_hooked = true;
21470 w->misc = 2;
21471 w->step = 0;
21472 theItem->clk2=256;
21473 Hero.doSwitchHook(game->get_switchhookstyle());
21474 if(QMisc.miscsfx[sfxSWITCHED])
21475 sfx(QMisc.miscsfx[sfxSWITCHED],int32_t(w->x));
21476 }
21477 }
21478 }
21479 }
21480 }
21481
6/6
✓ Branch 0 taken 43559 times.
✓ Branch 1 taken 498555 times.
✓ Branch 2 taken 374095 times.
✓ Branch 3 taken 330536 times.
✓ Branch 4 taken 498555 times.
✓ Branch 5 taken 330536 times.
542114 else if((w->id==wArrow&&itemsbuf[pitem].flags & item_flag2)||(w->id!=wArrow&&!(itemsbuf[pitem].flags & item_flag5)))//An arrow with "Picks up items" or a BRang/HShot without "Drags items"
21482 {
21483
2/2
✓ Branch 0 taken 87310 times.
✓ Branch 1 taken 374095 times.
461405 for(int32_t j=0; j<items.Count(); j++)
21484 {
21485
2/2
✓ Branch 0 taken 82412 times.
✓ Branch 1 taken 4898 times.
87310 if(items.spr(j)->hit(w))
21486 {
21487 4898 item *theItem = ((item*)items.spr(j));
21488 4898 bool priced = theItem->PriceIndex >-1;
21489
2/2
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 4766 times.
4898 bool isKey = itemsbuf[theItem->id].family==itype_key||itemsbuf[theItem->id].family==itype_lkey;
21490
5/8
✓ Branch 0 taken 4898 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4898 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3789 times.
✓ Branch 5 taken 1109 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2065 times.
6963 if(!theItem->fallclk && !theItem->drownclk && ((theItem->pickup & ipTIMER && theItem->clk2 >= 32)
21491
4/6
✓ Branch 0 taken 3174 times.
✓ Branch 1 taken 2065 times.
✓ Branch 2 taken 3174 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3174 times.
4898 || (((itemsbuf[pitem].flags & item_flag4)||(theItem->pickup & ipCANGRAB)||((itemsbuf[pitem].flags & item_flag7)&&isKey))&& !priced)))
21492 {
21493
1/2
✓ Branch 0 taken 1724 times.
✗ Branch 1 not taken.
5854 if(itemsbuf[theItem->id].collect_script)
21494 {
21495 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[theItem->id].collect_script, theItem->id & 0xFFF);
21496 }
21497
21498 1724 Hero.checkitems(j);
21499 1724 }
21500 4898 }
21501 87310 }
21502 374095 }
21503
2/2
✓ Branch 0 taken 14738 times.
✓ Branch 1 taken 153281 times.
829091 else if(w->id!=wArrow) //A BRang/HShot with "Drags Items"
21504 {
21505
2/2
✓ Branch 0 taken 36900 times.
✓ Branch 1 taken 153281 times.
190181 for(int32_t j=0; j<items.Count(); j++)
21506 {
21507
2/2
✓ Branch 0 taken 28212 times.
✓ Branch 1 taken 8688 times.
36900 if(items.spr(j)->hit(w))
21508 {
21509 8688 item *theItem = ((item*)items.spr(j));
21510 8688 bool priced = theItem->PriceIndex >-1;
21511
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 8681 times.
8688 bool isKey = itemsbuf[theItem->id].family==itype_key||itemsbuf[theItem->id].family==itype_lkey;
21512
4/6
✓ Branch 0 taken 8688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8688 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8454 times.
✓ Branch 5 taken 234 times.
8688 if(!theItem->fallclk && !theItem->drownclk && ((theItem->pickup & ipTIMER && theItem->clk2 >= 32)
21513
5/10
✓ Branch 0 taken 7273 times.
✓ Branch 1 taken 1181 times.
✓ Branch 2 taken 1415 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1415 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1415 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
8688 || (((itemsbuf[pitem].flags & item_flag4)||(theItem->pickup & ipCANGRAB)||((itemsbuf[pitem].flags & item_flag7)&&isKey)) && !priced && !(theItem->pickup & ipDUMMY))))
21514 {
21515 7273 int32_t pickup = theItem->pickup;
21516 7273 int32_t id2 = theItem->id;
21517 7273 int32_t pstr = theItem->pstring;
21518 7273 int32_t pstr_flags = theItem->pickup_string_flags;
21519
21520 7273 std::vector<int32_t> &ev = FFCore.eventData;
21521 7273 ev.clear();
21522 7273 ev.push_back(id2*10000);
21523 7273 ev.push_back(pickup*10000);
21524 7273 ev.push_back(pstr*10000);
21525 7273 ev.push_back(pstr_flags*10000);
21526 7273 ev.push_back(0);
21527 7273 ev.push_back(theItem->getUID());
21528 7273 ev.push_back(GENEVT_ICTYPE_RANGED_DRAG*10000);
21529 7273 ev.push_back(w->getUID());
21530
21531 7273 throwGenScriptEvent(GENSCR_EVENT_COLLECT_ITEM);
21532 7273 bool nullify = ev[4] != 0;
21533
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7273 times.
7273 if(nullify) continue;
21534
2/2
✓ Branch 0 taken 1076 times.
✓ Branch 1 taken 6197 times.
7273 if(w->id == wBrang)
21535 {
21536 6197 w->onhit(false);
21537 6197 }
21538
21539
2/2
✓ Branch 0 taken 6775 times.
✓ Branch 1 taken 498 times.
7273 if(w->dragging==-1)
21540 {
21541 498 w->dead=1;
21542 498 theItem->clk2=256;
21543 498 w->dragging=j;
21544 498 theItem->is_dragged = true;
21545 498 }
21546 7273 }
21547 8688 }
21548 36900 }
21549 153281 }
21550 542114 }
21551 3174751 }
21552 4854872 }
21553 14153855 void check_collisions()
21554 {
21555
2/2
✓ Branch 0 taken 4854837 times.
✓ Branch 1 taken 14153855 times.
19008692 for(uint q = 0; q < Lwpns.Count(); ++q)
21556 4854837 check_enemy_lweapon_collision((weapon*)Lwpns.spr(q));
21557 14153855 }
21558
21559 14156012 void dragging_item()
21560 {
21561
2/2
✓ Branch 0 taken 4970180 times.
✓ Branch 1 taken 14156012 times.
19126192 for(int32_t i=0; i<Lwpns.Count(); i++)
21562 {
21563 4970180 weapon *w = (weapon*)Lwpns.spr(i);
21564
21565
4/4
✓ Branch 0 taken 4507605 times.
✓ Branch 1 taken 462575 times.
✓ Branch 2 taken 4814921 times.
✓ Branch 3 taken 155259 times.
4970180 if((w->id == wBrang || w->id==wHookshot)&&itemsbuf[w->parentitem].flags & item_flag5)//item_flag5 is a port for qr_Z3BRANG_HSHOT
21566 {
21567
3/4
✓ Branch 0 taken 7247 times.
✓ Branch 1 taken 148012 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7247 times.
155259 if(w->dragging>=0 && w->dragging<items.Count())
21568 {
21569 7247 item* dragItem = (item*)items.spr(w->dragging);
21570 7247 dragItem->x=w->x;
21571 7247 dragItem->y=w->y;
21572
21573 // Drag the Fairy enemy as well as the Fairy item
21574 7247 int32_t id = dragItem->id;
21575
21576
4/4
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 6828 times.
✓ Branch 2 taken 404 times.
✓ Branch 3 taken 15 times.
7247 if(itemsbuf[id].family ==itype_fairy && itemsbuf[id].misc3)
21577 {
21578 404 movefairynew2(w->x,w->y,*dragItem);
21579 404 }
21580 7247 }
21581 155259 }
21582 4970180 }
21583 14156012 }
21584
21585 55 int32_t more_carried_items()
21586 {
21587 55 int32_t hasmorecarries = 0;
21588
21589
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 55 times.
115 for(int32_t i=0; i<items.Count(); i++)
21590 {
21591
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 55 times.
60 if(((item*)items.spr(i))->pickup & ipENEMY)
21592 {
21593 55 hasmorecarries++;
21594 55 }
21595 60 }
21596
21597 55 return hasmorecarries;
21598 }
21599
21600 // messy code to do the enemy-carrying-the-item thing
21601 14156012 void roaming_item()
21602 {
21603
4/4
✓ Branch 0 taken 28207 times.
✓ Branch 1 taken 14127805 times.
✓ Branch 2 taken 70 times.
✓ Branch 3 taken 28137 times.
14156012 if(!(hasitem&(4|2)) || !loaded_enemies)
21604 14127875 return;
21605
21606 // All enemies already dead upon entering a room?
21607
1/2
✓ Branch 0 taken 28137 times.
✗ Branch 1 not taken.
28137 if(guys.Count()==0)
21608 {
21609 return;
21610 }
21611
21612 // Lost track of the carrier?
21613
5/6
✓ Branch 0 taken 28137 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 28131 times.
✓ Branch 3 taken 6 times.
✓ Branch 4 taken 28115 times.
✓ Branch 5 taken 16 times.
28137 if(guycarryingitem<0 || guycarryingitem>=guys.Count() ||
21614 28131 !((enemy*)guys.spr(guycarryingitem))->itemguy)
21615 {
21616 22 guycarryingitem=-1;
21617
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 84 times.
84 for(int32_t j=0; j<guys.Count(); j++)
21618 {
21619
2/2
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 22 times.
84 if(((enemy*)guys.spr(j))->itemguy)
21620 {
21621 22 guycarryingitem=j;
21622 22 break;
21623 }
21624 62 }
21625 22 }
21626
21627
2/2
✓ Branch 0 taken 28073 times.
✓ Branch 1 taken 64 times.
28137 if(hasitem&4)
21628 {
21629 64 guycarryingitem = -1;
21630
21631
2/2
✓ Branch 0 taken 413 times.
✓ Branch 1 taken 64 times.
477 for(int32_t i=0; i<guys.Count(); i++)
21632 {
21633
2/2
✓ Branch 0 taken 349 times.
✓ Branch 1 taken 64 times.
413 if(((enemy*)guys.spr(i))->itemguy)
21634 {
21635 64 guycarryingitem = i;
21636 64 }
21637 413 }
21638
21639
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(guycarryingitem == -1) //This happens when "default enemies" such as
21640 {
21641 return; //eSHOOTFBALL are alive but enemies from the list
21642 } //are not. Defer to HeroClass::checkspecial().
21643
21644 64 int32_t Item=tmpscr->item;
21645
21646 64 hasitem &= ~4;
21647
21648
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 64 times.
64 if((!getmapflag(mITEM) || (tmpscr->flags9&fITEMRETURN)) && (tmpscr->hasitem != 0))
21649 {
21650 115 additem(0,0,Item,ipENEMY+ipONETIME+ipBIGRANGE
21651
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 13 times.
64 + (((tmpscr->flags3&fHOLDITEM) || (itemsbuf[Item].family==itype_triforcepiece)) ? ipHOLDUP : 0)
21652 );
21653 64 hasitem |= 2;
21654 64 }
21655 else
21656 {
21657 return;
21658 }
21659 64 }
21660
21661
2/2
✓ Branch 0 taken 29483 times.
✓ Branch 1 taken 28137 times.
57620 for(int32_t i=0; i<items.Count(); i++)
21662 {
21663
2/2
✓ Branch 0 taken 1346 times.
✓ Branch 1 taken 28137 times.
29483 if(((item*)items.spr(i))->pickup&ipENEMY)
21664 {
21665
2/2
✓ Branch 0 taken 14272 times.
✓ Branch 1 taken 13865 times.
28137 if(get_qr(qr_HIDECARRIEDITEMS))
21666 {
21667 14272 items.spr(i)->x = -128; // Awfully inelegant, innit?
21668 14272 items.spr(i)->y = -128;
21669 14272 }
21670
2/4
✓ Branch 0 taken 13865 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 13865 times.
13865 else if(guycarryingitem>=0 && guycarryingitem<guys.Count())
21671 {
21672
1/2
✓ Branch 0 taken 13865 times.
✗ Branch 1 not taken.
13865 if (!get_qr(qr_BROKEN_ITEM_CARRYING))
21673 {
21674 if (get_qr(qr_ENEMY_DROPS_USE_HITOFFSETS))
21675 {
21676 items.spr(i)->x = guys.spr(guycarryingitem)->x+guys.spr(guycarryingitem)->hxofs+(guys.spr(guycarryingitem)->hit_width/2)-8;
21677 items.spr(i)->y = guys.spr(guycarryingitem)->y+guys.spr(guycarryingitem)->hyofs+(guys.spr(guycarryingitem)->hit_height/2)-10;
21678 }
21679 else
21680 {
21681 if(guys.spr(guycarryingitem)->extend >= 3)
21682 {
21683 items.spr(i)->x = guys.spr(guycarryingitem)->x+(guys.spr(guycarryingitem)->txsz-1)*8;
21684 items.spr(i)->y = guys.spr(guycarryingitem)->y-2+(guys.spr(guycarryingitem)->tysz-1)*8;
21685 }
21686 else
21687 {
21688 items.spr(i)->x = guys.spr(guycarryingitem)->x;
21689 items.spr(i)->y = guys.spr(guycarryingitem)->y - 2;
21690 }
21691 }
21692 items.spr(i)->z = guys.spr(guycarryingitem)->z;
21693 items.spr(i)->fakez = guys.spr(guycarryingitem)->fakez;
21694 }
21695 else
21696 {
21697 13865 items.spr(i)->x = guys.spr(guycarryingitem)->x;
21698 13865 items.spr(i)->y = guys.spr(guycarryingitem)->y - 2;
21699 13865 items.spr(i)->fakez = guys.spr(guycarryingitem)->fakez;
21700 }
21701 13865 }
21702 28137 }
21703 29483 }
21704 14156012 }
21705
21706 bool enemy::IsBigAnim()
21707 {
21708 return (anim == a2FRMB || anim == a4FRM8EYEB || anim == a4FRM4EYEB
21709 || anim == a4FRM8DIRFB || anim == a4FRM4DIRB || anim == a4FRM4DIRFB
21710 || anim == a4FRM8DIRB);
21711 }
21712 2389914 int32_t enemy::getFlashingCSet()
21713 {
21714 //Special cset for the dying sprite
21715
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2389914 times.
2389914 if(dying)
21716 {
21717 if (!get_qr(qr_HARDCODED_ENEMY_ANIMS) || BSZ || fading == fade_blue_poof)
21718 return wpnsbuf[spr_death].csets & 15;
21719 else
21720 return (((clk2 + 5) >> 1) & 3) + 6;
21721 }
21722
21723 //Normal cset
21724
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2389914 times.
2389914 if (hclk <= 0)
21725 {
21726 //Special cset for the flashing animation
21727 if (flags & guy_flashing)
21728 return (frame & 3) + 6;
21729 return cs;
21730 }
21731
21732 //Hurt animations
21733
2/2
✓ Branch 0 taken 3888 times.
✓ Branch 1 taken 2386026 times.
2389914 if(family==eeGANON)
21734 3888 return (((hclk-1)>>1)&3)+6;
21735
4/4
✓ Branch 0 taken 2217173 times.
✓ Branch 1 taken 168853 times.
✓ Branch 2 taken 487138 times.
✓ Branch 3 taken 1730035 times.
2386026 else if(hclk<33 && !get_qr(qr_ENEMIESFLICKER))
21736 1730035 return (((hclk-1)>>1)&3)+6;
21737
21738 655991 return cs;
21739 2389914 }
21740
21741 81530246 bool enemy::is_hitflickerframe(bool olddrawing)
21742 {
21743
6/6
✓ Branch 0 taken 81501742 times.
✓ Branch 1 taken 28504 times.
✓ Branch 2 taken 3940244 times.
✓ Branch 3 taken 77561498 times.
✓ Branch 4 taken 3167553 times.
✓ Branch 5 taken 772691 times.
81530246 if (family == eeGANON || !hclk || !get_qr(qr_ENEMIESFLICKER))
21744 80757555 return false;
21745
21746
3/4
✓ Branch 0 taken 496051 times.
✓ Branch 1 taken 276640 times.
✓ Branch 2 taken 496051 times.
✗ Branch 3 not taken.
772691 if (!olddrawing && !getCanFlicker())
21747 return false;
21748
21749 772691 int32_t fr = game->get_spriteflickerspeed();
21750
1/2
✓ Branch 0 taken 772691 times.
✗ Branch 1 not taken.
772691 if (fr == 0)
21751 return true;
21752 772691 return frame % (fr * 2) < fr;
21753 81530246 }
21754
21755 const char *old_guy_string[OLDMAXGUYS] =
21756 {
21757 "(None)","Abei","Ama","Merchant","Moblin","Fire","Fairy","Goriya","Zelda","Abei 2","Empty","","","","","","","","","",
21758 // 020
21759 "Octorok (L1, Slow)","Octorok (L2, Slow)","Octorok (L1, Fast)","Octorok (L2, Fast)","Tektite (L1)",
21760 // 025
21761 "Tektite (L2)","Leever (L1)","Leever (L2)","Moblin (L1)","Moblin (L2)",
21762 // 030
21763 "Lynel (L1)","Lynel (L2)","Peahat (L1)","Zora","Rock",
21764 // 035
21765 "Ghini (L1, Normal)","Ghini (L1, Phantom)","Armos","Keese (CSet 7)","Keese (CSet 8)",
21766 // 040
21767 "Keese (CSet 9)","Stalfos (L1)","Gel (L1, Normal)","Zol (L1, Normal)","Rope (L1)",
21768 // 045
21769 "Goriya (L1)","Goriya (L2)","Trap (4-Way)","Wall Master","Darknut (L1)",
21770 // 050
21771 "Darknut (L2)","Bubble (Sword, Temporary Disabling)","Vire (Normal)","Like Like","Gibdo",
21772 // 055
21773 "Pols Voice (Arrow)","Wizzrobe (Teleporting)","Wizzrobe (Floating)","Aquamentus (Facing Left)","Moldorm",
21774 // 060
21775 "Dodongo","Manhandla (L1)","Gleeok (1 Head)","Gleeok (2 Heads)","Gleeok (3 Heads)",
21776 // 065
21777 "Gleeok (4 Heads)","Digdogger (1 Kid)","Digdogger (3 Kids)","Digdogger Kid (1)","Digdogger Kid (2)",
21778 // 070
21779 "Digdogger Kid (3)","Digdogger Kid (4)","Gohma (L1)","Gohma (L2)","Lanmola (L1)",
21780 // 075
21781 "Lanmola (L2)","Patra (L1, Big Circle)","Patra (L1, Oval)","Ganon","Stalfos (L2)",
21782 // 080
21783 "Rope (L2)","Bubble (Sword, Permanent Disabling)","Bubble (Sword, Re-enabling)","Shooter (Fireball)","Item Fairy ",
21784 // 085
21785 "Fire","Octorok (Magic)", "Darknut (Death Knight)", "Gel (L1, Tribble)", "Zol (L1, Tribble)",
21786 // 090
21787 "Keese (Tribble)", "Vire (Tribble)", "Darknut (Splitting)", "Aquamentus (Facing Right)", "Manhandla (L2)",
21788 // 095
21789 "Trap (Horizontal, Line of Sight)", "Trap (Vertical, Line of Sight)", "Trap (Horizontal, Constant)", "Trap (Vertical, Constant)", "Wizzrobe (Fire)",
21790 // 100
21791 "Wizzrobe (Wind)", "Ceiling Master ", "Floor Master ", "Patra (BS Zelda)", "Patra (L2)",
21792 // 105
21793 "Patra (L3)", "Bat", "Wizzrobe (Bat)", "Wizzrobe (Bat 2) ", "Gleeok (Fire, 1 Head)",
21794 // 110
21795 "Gleeok (Fire, 2 Heads)", "Gleeok (Fire, 3 Heads)","Gleeok (Fire, 4 Heads)", "Wizzrobe (Mirror)", "Dodongo (BS Zelda)",
21796 // 115
21797 "Dodongo (Fire) ","Trigger", "Bubble (Item, Temporary Disabling)", "Bubble (Item, Permanent Disabling)", "Bubble (Item, Re-enabling)",
21798 // 120
21799 "Stalfos (L3)", "Gohma (L3)", "Gohma (L4)", "NPC 1 (Standing) ", "NPC 2 (Standing) ",
21800 // 125
21801 "NPC 3 (Standing) ", "NPC 4 (Standing) ", "NPC 5 (Standing) ", "NPC 6 (Standing) ", "NPC 1 (Walking) ",
21802 // 130
21803 "NPC 2 (Walking) ", "NPC 3 (Walking) ", "NPC 4 (Walking) ", "NPC 5 (Walking) ", "NPC 6 (Walking) ",
21804 // 135
21805 "Boulder", "Goriya (L3)", "Leever (L3)", "Octorok (L3, Slow)", "Octorok (L3, Fast)",
21806 // 140
21807 "Octorok (L4, Slow)", "Octorok (L4, Fast)", "Trap (8-Way) ", "Trap (Diagonal) ", "Trap (/, Constant) ",
21808 // 145
21809 "Trap (/, Line of Sight) ", "Trap (\\, Constant) ", "Trap (\\, Line of Sight) ", "Trap (CW, Constant) ", "Trap (CW, Line of Sight) ",
21810 // 150
21811 "Trap (CCW, Constant) ", "Trap (CCW, Line of Sight) ", "Wizzrobe (Summoner)", "Wizzrobe (Ice) ", "Shooter (Magic)",
21812 // 155
21813 "Shooter (Rock)", "Shooter (Spear)", "Shooter (Sword)", "Shooter (Fire)", "Shooter (Fire 2)",
21814 // 160
21815 "Bombchu", "Gel (L2, Normal)", "Zol (L2, Normal)", "Gel (L2, Tribble)", "Zol (L2, Tribble)",
21816 // 165
21817 "Tektite (L3) ", "Spinning Tile (Combo)", "Spinning Tile (Enemy Sprite)", "Lynel (L3) ", "Peahat (L2) ",
21818 // 170
21819 "Pols Voice (Magic)", "Pols Voice (Whistle)", "Darknut (Mirror) ", "Ghini (L2, Fire) ", "Ghini (L2, Magic) ",
21820 // 175
21821 "Grappler Bug (HP) ", "Grappler Bug (MP) "
21822 };
21823